Functional layers & Models in Unix
Levels of Unix Software
- Unix users a layer approach of defining software layered approach is basis for Unix Security.
- At the lowest level, the level closest to the hardware, are the basic hardware interface modules
- process scheduling
- Memory management
- interrupt handling
- low level device control
- disk system management & data buffering
- process synchronization and inter – process communication ( 1pc)
Unix Functional layer Model
Kernel Service layer
File / disk access service
process creation and termination
Mapping between user requests and device driver actions.
The next level provides all the kernel services
The user system call is converted to a Kernel service call that actually performs the requests service
Terminal handling services
System call Interface Layer
The system call interface layer converts a process running in user mode to a protected kernel mode process.
This allows the program to invoke protected kernel routines to perform system functions.
User process Layer
The uppermost layer consists of user process running :
- Unix commands
- Utility programs
- User application program
*protected from other users
*Have no access to Unix Kernel routines except through system call interface
*cannot directly access Kernel memory space.
Kernel VS User space
In addition to the software levels, Unix also features two “rings of protection ” from inadvertent programming errors or malisons 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 is the area in memory when user process are run
This consist of memory starting above the kernel and includes the4 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 in user mode.
Kernel space is the region at memory where all kernel service are provided via kernel process.
Any process executing in kernel space is said to be executing in kernel mode.
Kernel Space is a privileged area ; the 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.
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 executes kernel code.
Data Flow Between Kernel and user Space
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 user area of the calling process.
User area of a process contains information a bout the process the Kernel needs while the process is running.
Open files , root, current directory, arguments to current system call , and process text, stack and data segment sizes.
A pointer to the process table entry containing information for scheduling such as priority.
User file descriptor table and information about open files.
Kernel Stack for the process.
Remember , user can not access Kernel space but Kernel space can access user space.