Presentation is loading. Please wait.

Presentation is loading. Please wait.

OPERATING SYSTEMS - I. What is an Operating System OS is a program that manages the computer hardware It provides a basis for application programs and.

Similar presentations


Presentation on theme: "OPERATING SYSTEMS - I. What is an Operating System OS is a program that manages the computer hardware It provides a basis for application programs and."— Presentation transcript:

1 OPERATING SYSTEMS - I

2 What is an Operating System 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 Classification of systems (hardware) Mainframes Time-sharing Systems Desktop Systems Multi-processor systems Distributed systems

4 Functions of an OS 1.Memory Manager 2.Process Manager 3.Device Manager 4.Information Manager

5 Key tasks in resource management 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 OS as a Process Manager 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. Image inspired by Galvin

7 How does it manages this? 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 How does the OS keep track of process states? 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 Process switching mechanism 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 Process Scheduling 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 Types of schedulers: 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 Operations on a process: Process Creation Process termination

13 The dispatcher 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 Pre-emption 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 CPU scheduling policies First Come First Served Shortest job First Priority Scheduling Round Robin Scheduling Multilevel Queue Scheduling Multiprocessor scheduling Realtime scheduling

16 Deadlocks 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 Conditions necessary for deadlock Mutual Exclusion Hold & Wait No preemption Circular wait

18 Deadlock handling Deadlock prevention  Break one of the conditions Deadlock avoidance  Intelligent allocation of resources Detection & Repair  Periodically check for a deadlock and break it

19 Process Synchronization Co-operating Processes may be sharing some data Concurrent access to shared data may cause data inconsistencies We must avoid this race condition

20 Critical Section 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 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 Classical Synchronization Problems The Bounded Buffer Problem The Readers-Writes Problem The Dining-Philosophers Problem

23 Memory Management 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. Image inspired by Galvin

24 Logical and Physical Memory 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 Dynamic loading Here parts of the program are loaded only on requirement Overlays Old method, implemented by the programmer to allow for larger programs

26 Swapping 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 Contiguous Memory requirement 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 Memory Protection 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 Memory Allocation 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 Fragmentation 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 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 Page Table The mapping of pages to frames is maintained in the page table. Segmentaion Segmentation is similar to paging with variable sized pages. This makes it more space efficient, but more difficult to manage.

33 Virtual Memory 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 Page Replacement 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 Global and Local Page Replacement 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 Thrashing 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 Device Management 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. Image inspired by Galvin

38 Device Characteristics 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 Disk Scheduling 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 Information Management 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 Directory Structure Single Level Two Level Tree structure Graph directories


Download ppt "OPERATING SYSTEMS - I. What is an Operating System OS is a program that manages the computer hardware It provides a basis for application programs and."

Similar presentations


Ads by Google