1
|
|
2
|
- OS is a program that manages the computer hardware
- It provides a basis for application programs and acts as an intermediary
between the user and the computer hardware
|
3
|
- Mainframes
- Time-sharing Systems
- Desktop Systems
- Multi-processor systems
- Distributed systems
|
4
|
- Memory Manager
- Process Manager
- Device Manager
- Information Manager
|
5
|
- Keep track of the resource being managed
- Decide an efficient allocation scheme for the resource
- Allocate the resource
- Reclaim the resource when it is not needed
|
6
|
- What is a process? It is a program in execution, stored in the main
memory, utilizing system resources.
- Need of Process Management:
- A multi-user/multi-programming
environment has several processes running concurrently with the
CPU switching between them.
- The OS manages their
execution.
|
7
|
- Each process is in a certain state at any instant of time:
- New process that has just come in for execution
- A process that is ready to run
- A process that is already running
- A process that is waiting for some event/ resource and its execution is
paused
- A process that has terminated
|
8
|
- The OS maintains the state of each process in a special structure called
the Process Control Block (PCB)
- The main components of the PCB are:
- Pointer to the location of the program
- Process state
- Process ID
- Program Counter
- Registers
- Memory limits
- List of open files
- CPU scheduling information
- Device usage information
|
9
|
- When the CPU switches from one process to another, the state of the
currently executing process is saved in its PCB.
- The state of the next process is loaded from its PCB and the CPU starts
working on it.
|
10
|
- Determining which process will execute when, and for how long is called
process scheduling
- For this, the OS maintains several Queues:
- Job Queue
- Ready Queue
- Device Queue
|
11
|
- Long Term Scheduler
- Handles fresh processes
- Least frequent
- Must select a good mix of CPU and IO intensive programs
- Medium Term Scheduler
- Creates batches for the short term scheduler
- Swaps out inactive processes
- Short Term Scheduler
- Picks out the deserving process for giving the CPU
- Most frequently used, must be very fast
|
12
|
- Process Creation
- Process termination
|
13
|
- It is that component that performs the actual CPU control transfer from
one process to another.
- The dispatcher latency has a major impact on system efficiency
|
14
|
- Preemption is a policy which requires a lot of thought before
implementing
- With this enabled, a high priority process can replace a running process
- Without this, we must rely on the process to voluntarily give up the CPU
control
|
15
|
- First Come First Served
- Shortest job First
- Priority Scheduling
- Round Robin Scheduling
- Multilevel Queue Scheduling
- Multiprocessor scheduling
- Realtime scheduling
|
16
|
- A deadlock is like a traffic jam on a roundabout
- A process P1 has a resource for which another process P2 is waiting. Now
P1 requests for a resource which is currently allocated to P2. Now both
will wait for each other forever.
- This 2 process example can be extended to any number of processes
|
17
|
- Mutual Exclusion
- Hold & Wait
- No preemption
- Circular wait
|
18
|
- Deadlock prevention
- Break one of the conditions
- Deadlock avoidance
- Intelligent allocation of resources
- Detection & Repair
- Periodically check for a deadlock and break it
|
19
|
- Co-operating Processes may be sharing some data
- Concurrent access to shared data may cause data inconsistencies
- We must avoid this race condition
|
20
|
- Each process has a segment of code in which it is modifying a shared
piece of data. This section is called the Critical Section.
- Synchronization can be maintained by ensuring that no two processes are
in their critical sections at the same time.
|
21
|
- Semaphores are like signal flags which can be used to mange the critical
section
- Semaphores can be accessed only by 2 atomic operations : signal &
wait
|
22
|
- The Bounded Buffer Problem
- The Readers-Writes Problem
- The Dining-Philosophers Problem
|
23
|
- A program can execute only if it is loaded in the main memory
- In multiprogramming, several processes have to run simultaneously
- Loading and unloading the process, responding to memory allocation
requests, and de-allocation are the jobs OS performs as a Memory
Manager.
|
24
|
- Logical memory : The image of the memory as seen by the process running
on the CPU
- Physical memory : The real hardware memory, which is not always directly
presented to the process
|
25
|
- Here parts of the program are loaded only on requirement
|
26
|
- To increase multiprogramming, we can move waiting processes from
Physical memory to backing store device to make room for new processes.
- Processes in the backing store can similarly be loaded back into memory
- This is called swapping.
|
27
|
- Almost all programs want to have contiguous memory allocated to them
- This complicates the task of memory management as we have to deal with
problems like fragmentation etc.
- We will see later how they are partially removed by techniques like
paging and segmentation
|
28
|
- We have to protect the Operating System from user processes, and also
protect user processes from one another
- We can provide this protection by using relocation registers.
|
29
|
- Empty blocks of various sizes are scattered around the memory at any
given time
- When a process is to be loaded in the memory, we have to decide where to
place it. We use these three algorithms:
- 1. First Fit
- 2. Best Fit
- 3. Worst Fit
|
30
|
- If the sum of all the free blocks is larger than the process size, but
no single block is large enough to accommodate the process, the process
cannot be loaded.
- This is known as Fragmentation (more precisely External Fragmentation)
- External Fragmentation can be removed by regular compaction.
- Internal Fragmentation can be better understood with paging
|
31
|
- Paging is a scheme which permit the physical address space of a process
to be non-contiguous.
- Physical memory is split into fixed size blocks called frames.
- The logical memory of the process is also broken into blocks of same
size called frames.
- Each process is allocated the required number of frames.
- The wastage of space inside the final page is called internal
fragmentation.
|
32
|
- The mapping of pages to frames is maintained in the page table.
|
33
|
- Virtual Memory allows a process to start execution with only a few of
its pages loaded in the memory.
- Pages requested by the process which are not loaded cause a Page Fault
and the page must be loaded now.
|
34
|
- As more pages are loaded, memory tends to get full, so some pages need
to be unloaded to the disk.
- The following algorithms help to decide which pages to offload:
- FIFO Page Replacement
- Optimal Page Replacement
- Least Recently Used (LRU) Page Replacement
|
35
|
- With Global Page Replacement, a process can replace the pages of any
process.
- In Local Page Replacement the process can replace only its own pages.
|
36
|
- With global page replacement, a condition can occur where the number of
page faults, increases very high, with most of the processes waiting for
their pages to be loaded. The scheduler loads up more processes to try
to increase CPU utilization, which further aggravates the problem,
decreasing the throughput.
|
37
|
- Dedicated device : A device that can be used one at a time only. Eg. a
card reader
- Shared Device : Two or more users can simultaneously use the device.
- Virtual Device : This converts a dedicated device to a shred device by
employing spooling technique.
|
38
|
- The device can be an IO device.
- The device can be a storage device.
- Access time:
- Serial Device (Eg Tape Drive)
- Completely Direct Serial Access Device (grid memory)
- Direct Access Device (Hard Disk)
|
39
|
- With several requests coming for
disk access, it is necessary to properly organize retrievals for maximum
efficiency.
- Disk Scheduling Algorithms:
- FCFS
- SSTF
- Scan scheduling
- C-scan scheduling
- Look Scheduling
- C-look
|
40
|
- File Concept: There are many storage mediums available. The OS abstracts
the physical properties of the storage device to define a logical
storage unit – the file.
|
41
|
- Single Level
- Two Level
- Tree structure
- Graph directories
|