Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University.

Similar presentations


Presentation on theme: "CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University."— Presentation transcript:

1 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University Department of Computer Engineering

2 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 2 Memory Management Memory is an important resource that must be carefully managed. Cost, size, and volatility are important parameters of memory chips. There is no single memory technology that is good in all these parameters. Therefore we have a memory hierarchy Registers, Cache, Main Memory, Disk, Tape… The part of the OS that manages the memory hierarchy is called the Memory Manager.

3 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 3 Memory Manager Jobs Its is job is to keep track of which parts of memory are used by which programs and which parts are free. Allocate memory when programs need it, and de-allocate it when programs finished. Manage swapping of programs between memory and disk.

4 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 4 Basic Memory Management Two classes of memory management systems  That move processes back and forth between memory and disk  That have all processes in memory during execution until termination.  We will look to this first.

5 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 5 Basic Memory Management Memory management that has a process in memory until termination.  Mono-programming without Swapping or Paging  Multiprogramming with Fixed Partitions  Modeling Multiprogramming Analysis of Multiprogramming System Performance  Relocation and Protection

6 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 6 Mono-programming Run one program at a time OS and one program will exists in the memory Operating System in RAM User Program 0 0xFFFF.. User Program In RAM Operating System in ROM 0 Device Drivers in ROM Operating System in RAM User Program in RAM 0 a) b)c) Early Mainframes Palmtop Computers and Embedded Systems MS-DOS running Early PCs

7 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 7 Multiprogramming with Fixed Partitions Modern systems allow multiple programs to run at the same time. This allows high CPU utilization:  While a process in blocked for I/O, an other one can use CPU. Divides the memory into n partitions (possible each with different sizes) The partitioning can be done at system boot up time.

8 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 8 Ways to use fixed partitions - 1 Partition 4 0 100K 200K 400K 700K 800K Partition 3 Partition 2 Partition 1 Operating System Operating System Multiple Input Queues. When a job arrives, put it into a queue for the first partition that is big enough to hold the job in memory.

9 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 9 Ways to use fixed partitions - 2 Partition 4 0 100K 200K 400K 700K 800K Partition 3 Partition 2 Operating System Operating System Single Input Queue When job arrives, they are put into a single input queue Partition 1 Which job to select when a partition becomes free?

10 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 10 Ways to use fixed partitions - 2 Selecting a Job when a partition become free!  1) Select the first job from the start of queue that fits in to the available partition.  2) Search all the jobs and find the largest sized job that fits into the available partition.  Discriminates against small jobs.  Solve by counting the skip overs for the fitting jobs. If a job is skipped k times, then don’t skip it in the next search

11 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 11 Modeling Multiprogramming Multiprogramming improves CPU utilization. Assume a process spends a fraction p (0<=p<=1) of its waiting for I/O to complete. With n process in memory (n: degree of multiprogramming):  The chance that all n processes are waiting for I/O is: p n  The CPU utilization is then: 1-p n.

12 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 12 80% I/O Wait 50% I/O Wait 20% I/O Wait

13 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 13 80% average I/O wait Memory Size OS Size program Size #programs that can fit (degree of multiprogramin g) CPU utilization Percent Increase in CPU utilization 32MB16MB4MB460%- 48MB16MB4MB883%38% 64MB16MB4MB1293%12%

14 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 14 Analysis of Multiprogramming Systems Assume 4 jobs arrive to a batch system ayt 10:00 am in the morning precisely at the following moments:  Job 1: 10:00am (requires 4 minutes of CPU)  Job 2: 10:10am (requires 3 minutes of CPU)  Job 3: 10:15am (requires 2 minutes of CPU)  Job 4: 10:20am (requires 1 minute of CPU) When does each job completes?

15 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 15 Analysis of Multiprogramming Systems Process 1 Process 2 Process 3 Process 4 CPU idle.80.64.51.41pnpn CPU busy.20.36.49.591-p n CPU/process.20.18.16.15(1-p n )/n p = 0.8 and n is in {1, 2, 3, 4}

16 CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University 16 Analysis of Multiprogramming Systems 10 201531.7 28.2 27.6 22 2.0.9.8.3.9.8.3.9.3.1.7 minutes Time minutes 0 4 3 2 1 Job 2 starts Job 2 ends Job 1 ends Time is relative to Job 1’s arrival Job 3 ends Job 3 starts


Download ppt "CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent University."

Similar presentations


Ads by Google