Nothing is better than a birds eye-view 🦅
- GE and MIT joined together to develop multics, But it failed.
- Ken Thompson and Dennis Ritchie drew the plan for a new File system.
- Thompson programmed a kernel for it on a GE467 machine.
- Brian Kernighan joined them.
- They created the first version of unix and ran it on PDP-7.
- They moved it to PDP-11.
- Thompson tried to implement the system on Fortran, but created B.
- B was slow, so Ritchie created C.
- The Unix was rewritten in C in 1973
- They published paper in 1974.
- More than 500 Unix websites in 1977.
- They created an amalgamation of all the version as the Unix - III
- Unix - V was created From UNIX - III
- Written using C
- A good file system
- Everything in UNIX is treated as a file - Simplicity
- Fast processing speed.
- At the same time:
- Multiple users can use it
- Multiple process can run on it.
- UNIX abstracts the hardware to programs.
- Program use system calls to communicate.
- System Calls are also packaged into commands.
- 32/64 System calls are used.
- also a CC which gives a.out file.
- Tree like Structure
- Root - "/"
- path name contains name and /.
- Traverse Using the cd command
- . : current directory
- .. : parent directory
- directory is also an file, but Special.
- all internal nodes are directories
- External nodes (Leaf Nodes) can be a:
- Directory File
- Actual File
- Device File
- cp used to copy files
- Programs converted into process executing some task.
- Many such process can run at the same time.
- There are calls to create, kill and synchronize them.
- The directory in which a process run is its environment.
-
Shell is an program that can execute commands.
-
Commands are system calls packaged together.
-
This package could be:
- .exe
- .sh
-
The command is run by the syntax:
[CommandName] [Options] [Parameters]
-
When a command is run, the shell forks and exec the command's program file.
-
They could be run synchronously or asynchronously to the shell process.
-
Outputs of the commands can be:
- redirected (> and <) to files
- piped (|) between commands
- Free Space management
- File Protection
- Powers of UNIX upon Processes:
- Create
- Run
- Sleep
- Suspend
- Kill
- The processes in main memory and Secondary Memory managed by UNIX.
- Schedule their execution.
- Some UNIX powers given to shell
- The hardware must follow the two modes of execution.
- User
- Kernel
- The process in User mode upgrades to Kernel mode when upon System Call.
- After Execution, they return to User Mode.
- The hardware has devices that may interrupt the UNIX.
- The UNIX pauses current process, services Interrupt and resumes the Process execution.
- Process executes instructions run by the hardware.
- Sometime they put the machine into a state of confusion, called Exception.
- They are handled by UNIX.
- Interruption of important processes cannot be tolerated.
- Hence Processes are given levels to avoid critical process be stopped.
- Hardware must allow to storage of processes in Main memory and in Secondary Memory.
- Three layer architecture.
- communication from User to Kernel level through system calls
- called by library function
- called directly
- system call interact with:
- File system using:
- open
- close
- read
- write
- chown
- chmod
- Process system using:
- fork
- exec
- exit
- brk?
- signal?
- Hardware implicitly using:
- File system
- Process system
- File system using:
- These interactions are based on :
- File system:
- Buffer Cache
- Device Drivers
- Process System:
- Scheduling
- Memory Management
- IPC
- Hardware:
- Interrupt handling
- File system:
-
There are three structures
- Inode table
- File Table
- User File Descriptor Table
-
The disk Inode structure is loaded into main memory.
-
Inode table contains pointer to these in-memory copies.
-
The File table contains pointer to inodes.
-
Descriptor contains pointer to file table entries.
-
Processes can use this table to access and modify files.
-
NOTE: The root inode ("/") of filesystem is placed into memory when mounting.
- The disk can be divided into many file systems.
- Each filesystem contain:
- Boot block contain code to load the OS into memory.
- Not all file system has this boot block.
- Super block contains free space locations.
- Inode List for files.
- Data block of files.
- Process needs memory for :
- Text - Machine code
- Data - to store variable
- Stack - for function call
- Regions of memory given to the process, to store them.
- All process in the memory come from forking and exec.
- A process calling fork is parent and the new process is child.
- The exception to this is the process 0
-
To avoid process in user mode gaining kernel level information, seperate stacks for each mode.
Stack Frame Parameters Return Address Local Variables Address of previous Frame
- Four Data Structures:
- Region Table
- pregion Table
- Process Table
- U area
-
Regions are block of memory.
-
Region can be:
- Text
- Data
- Stack
-
Region Table has region's location and type.
-
Pregion Table points to region table.
-
process table points to pregion table.
-
U area points to process table
-
U area also contains information of process such as:
- Process size
- Pointer to File Descriptor
- Current Directory
- Current Root
-
Process Table contains:
- State Field
- UID
- Event Descriptor for suspension. NOTE: Root changes based on file system
All the activity of process:
- values in CPU register (PC, IR, PS,...)
- u area of the process
- user and kernel stack
- global variables
- Ready
- Executing in Kernel Mode
- Executing in User Mode
- Sleep
- The diagram is self-explanatory:
- Process put to sleep when process needs a event to ocuur.
- If event occurs then the process is woke up.
- All of the before said data structures are fixed size.
- There is a possiblility running out of entries.
- UNIX does not allow this problem, thanks to the way it's structured.
-
Administration include:
- creation of user and groups for different people.
- Installation of programs.
- File Permissions
- Disk formatting
etc...
-
From UNIX perspective, they are user processes.
-
A Super-User has priveleges to do these tasks.