unix system overview - kennesaw state university
TRANSCRIPT
UNIX System Overview
UNIX Architecture
● Kernel of os– Software that controls hardware resources
& provides environment under which programs can run
● System calls - Interface to kernel● Libraries of common functions – built on
top of system calls● Shell – interface for running other
programs
UNIX Architecture
Logging In
● Login name– Password file – usually in /etc/passwd
– 7 colon separated fields● Login name● Encrypted password● Numeric user id● Numeric group id● Comment field● Home directory● Shell program
Shells
● Command line interpreter – reads user input & executes commands
– Bourne shell – written by Steve Bourne
– C shell – written by Bill Joy
– Korn shell – written by David Korn
– Bourne-again shell (bash) – GNU shell
File System
● Hierarchical arrangement of files & directories
● Starts at root – symbolic name is /● Directory – file that contains directory
entries– Directory entry – filename & file attribute
● Size, owner, permissions, date last modified, ...
File Names
● Slash (/) & null characters – cannot appear in a file name
● . (current directory) & .. (parent directory) are automatically created
Pathname
● Sequence of 1 or more filenames separated by /'s & potentially starting with a /
● Start with / - absolute pathname● Otherwise – relative pathname
Directories
● Working directory– Current directory
● Home directory– Each user has home directory –
subdirectory of home
Input & Output
● File descriptor – non-negative integer used by kernel
● Predefined descriptors – automatically opened whenever new program is run
– Standard input
– Standard output
– Standard error
Input & Output
● Unbuffered I/O– Provided by functions open, read, write,
lseek, close
● Standard I/O– Buffered interface to unbuffered functions
– printf
– fgets
Programs & Processes
● Program – executable file on disk– Read into memory & executed by kernel
● Process – executing instance of a program– Process id – unique numeric identifier
● Process control– Fork
– Exec
– waitpid
Threads
● Threads within a process share address space
● Have own stack● Need to synchronize access to shared
variables● Each thread – own id
Error Handling
● System functions – usually return a numeric error flag - <error.h>
● Each thread needs its own copy of errno● Errno – not reinitialized each time – only
use if an error has occurred● Never set to 0● strerror – returns pointer to error message● perror – creates error message on
standard error
Error Recovery
● 2 types of errors: fatal & nonfatal● Fatal error – no recovery possible● Nonfatal – delay & try later
User Identification
● User ID - numeric value – assigned by system administrator when account is created
● root – id 0● Group id – assigned by system
administrator● Groups – collection of users with common
characteristics– Sharing of resources within group
Signals
● Technique to notify a process that a condition has occurred
● Choices for dealing with signal– Ignore
– Let default action occur
– Provide a function which is called
Time Values
● Calendar time – number of seconds since Epoch (Jan 1, 1970)
– time_t data type
● Process time – measures CPU resources used
– Measured in terms of clock ticks
– clock_t data type
Time Values
● Execution time of a process– Wall Clock time
● Amount of time for process to run
– User CPU time● CPU time for user instructions
– System CPU time● CPU time for kernel executing instructions
for user
● time command
System Calls & Library Functions
● System calls – functions to request services from kernel
● C library function with same name as system call