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.

Slides:



Advertisements
Similar presentations
Processes Management.
Advertisements

Part IV: Memory Management
Review: Chapters 1 – Chapter 1: OS is a layer between user and hardware to make life easier for user and use hardware efficiently Control program.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Operating System. Main goal of OS: –Run programs efficiently –Make the computer easier to use Provide a user-friendly interface –Improve the efficiency.
Memory Management Chapter 4. Memory hierarchy Programmers want a lot of fast, non- volatile memory But, here is what we have:
CS 104 Introduction to Computer Science and Graphics Problems
CMPT 300: Operating Systems Review THIS REIVEW SHOULD NOT BE USED AS PREDICTORS OF THE ACTUAL QUESTIONS APPEARING ON THE FINAL EXAM.
Memory Management 2010.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory.
Memory Management Chapter 5.
©Brooks/Cole, 2003 Chapter 7 Operating Systems Dr. Barnawi.
Computer Organization and Architecture
Silberschatz, Galvin and Gagne  Operating System Concepts Multistep Processing of a User Program User programs go through several steps before.
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
03/05/2008CSCI 315 Operating Systems Design1 Memory Management Notice: The slides for this lecture have been largely based on those accompanying the textbook.
CS364 CH08 Operating System Support TECH Computer Science Operating System Overview Scheduling Memory Management Pentium II and PowerPC Memory Management.
Layers and Views of a Computer System Operating System Services Program creation Program execution Access to I/O devices Controlled access to files System.
Chapter 3 Memory Management: Virtual Memory
Silberschatz and Galvin  Chapters 3 and 5 Possible questions –Tracing a given program involving fork, exec, semaphores, and share memory –Wring.
Swapping and Contiguous Memory Allocation. Multistep Processing of a User Program User programs go through several steps before being run. Program components.
MEMORY MANAGEMENT Presented By:- Lect. Puneet Gupta G.P.C.G. Patiala.
©Brooks/Cole, 2003 Chapter 7 Operating Systems. ©Brooks/Cole, 2003 Define the purpose and functions of an operating system. Understand the components.
Chapter 5 Operating System Support. Outline Operating system - Objective and function - types of OS Scheduling - Long term scheduling - Medium term scheduling.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
CIS250 OPERATING SYSTEMS Memory Management Since we share memory, we need to manage it Memory manager only sees the address A program counter value indicates.
SWE202 Review. Processes Process State As a process executes, it changes state – new: The process is being created – running: Instructions are being.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
Chapter 7 Operating Systems. Define the purpose and functions of an operating system. Understand the components of an operating system. Understand the.
Systems II San Pham CS /20/03. Topics Operating Systems Resource Management – Process Management – CPU Scheduling – Deadlock Protection/Security.
Chapter 4 Memory Management Virtual Memory.
Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Main Memory. Chapter 8: Memory Management Background Swapping Contiguous Memory Allocation Paging Structure of the Page Table Segmentation Example: The.
Memory Management Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only storage.
Memory management The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 8: Main Memory.
Computer Architecture Chapter (8): Operating System Support
Chapters 3 and 5 Possible questions
Memory Management.
Chapter 8: Main Memory.
Process Management Process Concept Why only the global variables?
William Stallings Computer Organization and Architecture
Section 10: Last section! Final review.
Lecture 10: Virtual Memory
Main Memory Management
Chapter 9: Virtual-Memory Management
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Multistep Processing of a User Program
Operating Systems.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Main Memory Background Swapping Contiguous Allocation Paging
Process & its States Lecture 5.
Operating Systems.
Chapter 8: Memory management
Outline Module 1 and 2 dealt with processes, scheduling and synchronization Next two modules will deal with memory and storage Processes require data to.
Chapter 8: Memory Management strategies
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
Chapter 3: Processes Process Concept Process Scheduling
Operating Systems Concepts
CSE 153 Design of Operating Systems Winter 2019
COMP755 Advanced Operating Systems
OPERATING SYSTEMS MEMORY MANAGEMENT BY DR.V.R.ELANGOVAN.
CSE 542: Operating Systems
Page Main Memory.
Presentation transcript:

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 acts as an intermediary between the user and the computer hardware

Classification of systems (hardware) Mainframes Time-sharing Systems Desktop Systems Multi-processor systems Distributed systems

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

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

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

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

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

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.

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

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

Operations on a process: Process Creation Process termination

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

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

CPU scheduling policies First Come First Served Shortest job First Priority Scheduling Round Robin Scheduling Multilevel Queue Scheduling Multiprocessor scheduling Realtime scheduling

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

Conditions necessary for deadlock Mutual Exclusion Hold & Wait No preemption Circular wait

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

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

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.

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

Classical Synchronization Problems The Bounded Buffer Problem The Readers-Writes Problem The Dining-Philosophers Problem

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

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

Dynamic loading Here parts of the program are loaded only on requirement Overlays Old method, implemented by the programmer to allow for larger programs

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.

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

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.

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

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

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.

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.

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.

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

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.

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.

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

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)

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

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.

Directory Structure Single Level Two Level Tree structure Graph directories