Professional Documents
Culture Documents
Unix Architecture
Unix Architecture
Typical OS includes a user interface or command interpreter Unix is somewhat unique in that the command interpreter is not integrated with the OS but is a separate program
Unix Architecture
At the lowest level, the level closest to the hardware, are the basic hardware interface modules
u Process
scheduling u Memory management u Interrupt handling u Low level device control u Disk system management and data buffering u Process synchronization and inter-process communication (IPC)
ITSW 2436/KRF Copyright 2001 by Kenneth R. Frazer
actions u The user system call is converted to a kernel service call that actually performs the requested service l Process creation and termination l I/O services l File/disk access services l Terminal handling services
The system call interface layer converts a process running in user mode to a protected kernel mode process
u This
allows the program to invoke protected kernel routines to perform system functions
User processes:
u Protected
from from other users u Have no access to Unix kernel routines except through the system call interface u Cannot directly access kernel memory space
7
q q
In addition to the software levels, Unix also features two "rings of protection" from inadvertent programming errors or malicious attacks that might damage other user's processes or the kernel's processes and data structures The inner protected ring is known as kernel space The outer ring is called user space
User Space
q q q q q
User space is the area in memory where user processes are run This consists of memory starting above the kernel and includes the rest of available memory This memory is protected; the system prevents one user from interfering with another Only kernel process can access a user process A process operating in this memory region is said to be operating in user mode
Kernel Space
q q q q q
Kernel space is the region of memory where all kernel services are provided via kernel processes Any process executing in kernel space is said to be executing in kernel mode Kernel space is a privileged area; the user has access to it only through the system call interface A user does not have direct access to either all machine instructions or devices A kernel process does have direct access to both
10
Also, a kernel process can modify the memory map, an operation frequently required to perform process scheduling A user process becomes a kernel process when it executes a system call and starts executing kernel code
11
q q
Since users and the kernel do not share memory address space, the mechanism for moving data between them is important When a system call is executed, the arguments to the call and the corresponding kernel routine identification are passed from user space to kernel space Kernel routine ID is usually passed either via a hardware machine register or via the stack System call arguments are passed in the u area (user area) of the calling process
12
u area of a process (user structure and kernel stack) contains information about the process the kernel needs while the process is running
u Open
files, root, current directory, arguments to current system call, and process text, stack, and data segment sizes u A pointer to the process table entry containing information for scheduling such as priority u User file descriptor table and information about open files u Kernel stack for the process (empty when executing in user mode)
Remember, user cannot access kernel space but kernel space can access user space 13 ITSW 2436/KRF Copyright 2001 by Kenneth R. Frazer
q
Unix command interface is a separate program referred to as the shell The shell provides the user interface between the user and the kernel Unix commands and utilities, like the shell, are also separate programs They are part of a Unix distribution, and are considered part of Unix but not part of the kernel
14
Unix provides a number of system services such as systems administration, system reconfiguration, and file system maintenance Other services include
u Customization
of system parameters u Rebuilding of kernel with user drivers u Creation and definition of user accounts u Set up and maintenance of access control parameters for files and peripherals
q
System calls provide a programming interface that allows user programs to access kernel functions There are a large number of system calls that perform functions to manage system resources such as memory, disk storage, and peripherals System calls are defined in a run-time library that provides a mapping of the system call interface to the kernel routine(s) that perform the system functions The shell also provides functionality equivalent to many of the system calls
16
Unix provides some general accounting services As each process terminates, an accounting record is made available describing the resources used by the process
u Name
of the process u Amount of user and system CPU time used u Elapsed (wall clock) time u Average amount of memory used u Number of disk I/O operations done u UID and GID of the process u Terminal from which the process was started
17
18