Layered Architecture
Unix System Architecture
- Unix system follows a layered approach . It has 4 Layers
- The inner most layer is the hardware layer.
- In the second layer , the KERNEL is placed.
- The utilities and other application programs form 3rd
- Fourth layer is the one with which the user actually interacts.
Kernel
- Kernel is that part of OS which directly makes interface with the hardware system.
Actions :
- Provides mechanism for creating and deleting processes.
- Provides processor scheduling, memory & I/0 management
- Provides inter – process communication
The Shell
- A utility program that comes with the UNIX system
Features of shell are :
- Interactive processing
- Back ground processing
- I/ O Redirection
- Pipes
- Shell Scripts
- Shell Variables
- Programming constructs
Process Management
- A process is a program in execution
- Several processes can be executed simultaneously a UNIX system.
- A process is generally created using the “fork ()”.system call
- The process that invokes the “fork ()” system call is the parent process, and the newly created process is called the child process
CPU Scheduling
- UNIX uses round – ration scheduling to support its multi-user and time – sharing feature.
- Round – robin fashion of scheduling is considered to be the oldest, simplest and widely used algorithm.
- Every process is given a time slice.
Memory Management
- Virtual memory
- Swap area
- Demand paging
File Management
- UNIX uses a hierarchical file system with ‘1’ as its root
- Every non – leaf node of the tree is called as directory file
- Every leaf node can either be a file, or an empty directory.
Types of UNIX users
- Broad classification of users
- root
- non-root
- Group
- Unix allows user ID’s to be grouped
- A single user ID can be member of multiple groups
- Differentiating users with respect to file access
-OWNER
-Group
-others
Working with UNIX
- User logs in with a valid user ID.
- User logs out to terminate the login session.
exec()
Excel, Excel p, Excel e, Excel v, Excel vp – executes a file
Synopsis
# include <Unistd. h>
Extern char ** en viron;
Int excel (const char * path , const char * arg,……………);
Int excel p (const char * file , const char * arg,……………);
Int excel e (const char * path , const char * avg,…, char * const envp [] ) ;
Return Value
If any of the exec () functions returns , an error will have occurred. The return value is -1, and the global variable err no will be set to indicate the error.
Files
/bin/sh
System ()
System - executes a shell command
Synopsis
# include <stdlib.h>
Int system (const char * command;)
Description
System () executes a command specified in command by calling /bin/sh – c command, and returns after the command has been completed. Using execution of the command , SIGCHLD will be blocked and SIGINT and SIGQUIT will be ignored.
Return Value
‘- 1’ on error
If the value of command is NULL, sys n () returns non – Zero if the shell is available and if not system () does not effect wait status of at other children .
PS:
$ PS:
PID | TTY | TIME | CMD |
2561 | Pts/0 | 00:00:00 | Bash |
2752 | Pts/0 | 00:00:00 | PS |
$ bash // opened bash for your own
$ Ps – l:
F | S | UID | PID | PPIS | 0 | PRI | NT | ADDR | S7 | WCHAN | TTY | TIME | CMD |
0 | S | 6524 | 2561 | 2559 | 0 | 75 | 0 | - | 1177 | wait | Pts/0 | 00:00:00 | Bash |
0 | S | 6524 | 2767 | 2561 | 0 | 76 | 0 | - | 1176 | Wait | Pts/0 | 00:00:00 | Bash |
0 | S | 6524 | 2785 | 2767 | 0 | 76 | 0 | - | 1084 | - | Pts/0 | 00:00:00 | PS |