Memory Allocation Policies Memory Allocation policies like Next

  • Slides: 28
Download presentation

Memory Allocation Policies Memory Allocation policies like Next fit, Best fit, Worst fit. Author

Memory Allocation Policies Memory Allocation policies like Next fit, Best fit, Worst fit. Author Aniket Phatak. Ameya Gawde. Daishik Mehta.

Objectives: After interacting with this Learning object; you will be able to: 1. Identify

Objectives: After interacting with this Learning object; you will be able to: 1. Identify the best placement algorithm 2. Construct the first fit, best fit, next fit and worst fit algorithm. 1. Identify the worst placement algorithm.

INSTRUCTIONS SLIDE 1 Master layout or diagram 2 3 4 5 Make a schematic

INSTRUCTIONS SLIDE 1 Master layout or diagram 2 3 4 5 Make a schematic diagram of the concept Explain the animator about the beginning and ending of the process. Draw image big enough for explaining. In above image, identify and label different components of the process/phenomenon. (These are like characters in a film) Illustrate the basic flow of action by using arrows. Use BOLD lines in the diagram, (minimum 2 pts. ) In the slide after that, provide the definitions of ALL the labels used in the diagram

1 2 3 4 Master Layout 1 Fig 1: P A R K I

1 2 3 4 Master Layout 1 Fig 1: P A R K I N G A R E A Images from the foll site: http: //darkdemon. org/bolt/sticks/ www. fotosearch. com/FSP 628/803054/ 5 www. speedysigns. com/decals/graphic_decal_8894. htm

1 2 3 4 Master Layout 2 Fig 1: Best Fig 2: Next Fit

1 2 3 4 Master Layout 2 Fig 1: Best Fig 2: Next Fit Comes 3 rd Comes 1 st Comes 2 nd P A R K I N G A R E A Comes 2 nd Comes 1 st Comes 6 th Comes 5 th P A R K I N G A R E A Comes 3 rd Comes 4 th Comes 5 th 5 The truck coming 6 th does not get parking Images from the foll site: http: //darkdemon. org/bolt/sticks/ www. speedysigns. com/decals/graphic_decal_8894. htm www. fotosearch. com/FSP 628/803054/

1 Master Layout 3 Fig 3: Worst fit Comes 1 st 2 3 4

1 Master Layout 3 Fig 3: Worst fit Comes 1 st 2 3 4 5 P A R K I N G A R E A Comes 4 th Both the trucks don’t get parking Comes 2 nd Comes 6 th Comes 5 th Comes 3 rd Images from the foll site: http: //darkdemon. org/bolt/sticks/ www. speedysigns. com/decals/graphic_decal_8894. htm www. fotosearch. com/FSP 628/803054/

1 Master Layout 4 Fig 4: First fit Comes 1 st 2 3 4

1 Master Layout 4 Fig 4: First fit Comes 1 st 2 3 4 5 Comes 2 nd P A R K I N G A R E A Comes 4 th Comes 3 rd Comes 5 th The truck does not get parking Comes 6 th Images from the foll site: http: //darkdemon. org/bolt/sticks/ www. speedysigns. com/decals/graphic_decal_8894. htm www. fotosearch. com/FSP 628/803054/

1 Master Layout 5 Fig 4 a: Next fit 2 3 Fig 4 b:

1 Master Layout 5 Fig 4 a: Next fit 2 3 Fig 4 b: Worst fit 4 176 K 388 K 5 388 K

1 Master Layout 6 Fig 4 c: Best fit 2 83 K 426 K

1 Master Layout 6 Fig 4 c: Best fit 2 83 K 426 K 88 K 88 K 288 K 88 K 3 Fig 4 d: First fit 4 5 183 K 176 K 183 K 426 K 176 K 183 K

1 2 Definitions of the components: Memory management: - It is the process of

1 2 Definitions of the components: Memory management: - It is the process of partitioning and allocating partitions to various processes. Partition: - It is the block of memory that can be fixed or made dynamically. Fragmentation: -The left over space inside the partition is called fragmentation. External Fragmentation: External fragmentation is the phenomenon in which free storage becomes divided into many small pieces over time. 3 For example, in dynamic memory allocation, a block of 1000 bytes might be requested, but the largest contiguous block of free space has only 300 bytes. Even if there are ten blocks of 300 bytes of free space, separated by allocated regions, one still cannot allocate the requested block of 1000 bytes, and the allocation request will fail. Internal fragmentation: Internal fragmentation is where the memory manager allocates more for each allocation than is actually requested. 4 For example, in many file systems, each file always starts at the beginning of a cluster, because this simplifies organization and makes it easier to grow files. Any space left over between the last byte of the file and the first byte of the next cluster is a form of internal fragmentation called file slack or slack space. Paging: Paging is a memory management technique that permits the physical address space of a program to be non-contiguous. Paging allocates memory in fixed-size chunks called pages. 5 Compaction: Compaction attacks the problem of fragmentation by moving all the allocated blocks to one end of memory, thus combining all the holes.

1 2 3 Explain the process 4 5 In this step, use an example

1 2 3 Explain the process 4 5 In this step, use an example to explain the concept. It can be an analogy, a scenario, or an action which explains this concept/process/topic Try to use examples from day-to-day life to make it more clear You have to describe what steps the animator should take to make your concept come alive as a series of moving images. Keep the examples simple to understand, and also to illustrate/animate.

1 2 3 4 Analogy / Scenario / Action Example: Parking Space Management Consider

1 2 3 4 Analogy / Scenario / Action Example: Parking Space Management Consider a scooter, car and truck are looking out space for parking. They arrive in the order mentioned below: Scooter Car Truck The parking spaces are available for each one of them as per their size constraints. (Fig 1) In the space for truck parking, a car and a scooter can be parked or even two scooters besides truck itself. Similarly, for car parking two scooters can be parked other than itself. 5 Click on play to see the Best fit, Worst fit and Next fit.

1 Stepwise description of process 2 3 4 5 The goal of the IDD

1 Stepwise description of process 2 3 4 5 The goal of the IDD is to provide instructions to an animator who is not a expert. You have to describe what steps the animator should take to make your concept come alive as a moving visualization. Use one slide per step. This will ensure clarity of the explanation. Add a image of the step in the box, and the details in the table below the box. You can use any images for reference, but mention about it's copyright status The animator will have to re-draw / re-create the drawings Add more slides as per the requirement of the animation

1 2 3 4 5 Step 1: Analogy

1 2 3 4 5 Step 1: Analogy

1 2 3 4 5 Step 2: Analogy

1 2 3 4 5 Step 2: Analogy

1 2 3 4 5 Step 3: Analogy

1 2 3 4 5 Step 3: Analogy

1 2 3 4 5 Step 4: Analogy

1 2 3 4 5 Step 4: Analogy

1 2 Animation design 3 4 5 Please see the design template provided in

1 2 Animation design 3 4 5 Please see the design template provided in the next slide. This is a sample template, and you are free to change as per your design requirements. Try and recreate the sections/subsections as shown in the template.

Suggestions Did you know? (entry behaviour) Radio buttons (if any) Drop down (if any)

Suggestions Did you know? (entry behaviour) Radio buttons (if any) Drop down (if any) Enter Play/pause Restart What will you learn Keywords Lets Learn! Definitions Value inputs (if any) Concepts Assumptions (if any) Formula with derivation (if any) If any of them are not mentioned in the IDD deleted Graphs/Diagram (for reference) Test your understanding (questionnaire) Lets Sum up (summary) Want to know more… (Further Reading) Summative evaluation Instructions/ Working area Feedback below the animation Area

1 Interactivity and Boundary limits 2 3 4 5 In this section, you will

1 Interactivity and Boundary limits 2 3 4 5 In this section, you will add the ‘Interactivity’ options to the animation. Use the template in the next slide to give the details. Insert the image of the step/s (explained earlier in the Section 3) in the box, and provide the details in the table below. The details of Interactivity could be: Types: Drop down, Slider bar, Data inputs etc. Options: Select one, Multiple selections etc Boundary Limits: Values of the parameters, which won’t show results after a particular point Results: Explain the effect of the interaction in this column Add more slides if necessary

1 Interactivity option: Step No: 5 Partition of memory blocks Process sizes 212 K

1 Interactivity option: Step No: 5 Partition of memory blocks Process sizes 212 K 2 112 K 426 K 3 4 5

1 Interactivity option: Step No: 6 Partition of memory blocks 2 3 4 5

1 Interactivity option: Step No: 6 Partition of memory blocks 2 3 4 5 No of Process: Process sizes

1 Interactivity option: Step No: 7 Partition of memory blocks No of Process: Process

1 Interactivity option: Step No: 7 Partition of memory blocks No of Process: Process sizes Best placement algorithm 2 3 4 5 Worst placement algorithm

INSTRUCTIONS SLIDE Questionnaire to test the user A small, (5 questions) questionnaire can be

INSTRUCTIONS SLIDE Questionnaire to test the user A small, (5 questions) questionnaire can be created in the next slide, to test the user's comprehension. This can be an objective type questionnaire. It can also be an exercise, based on the concept taught in this animation. Please give the answer key also.

Questionnaire 1 1. Which is the best placement algorithm? Answers: a) 2 Worst fit

Questionnaire 1 1. Which is the best placement algorithm? Answers: a) 2 Worst fit b) Best fit c) Next fit d) None of them c) Worst fit d) None of them 2. Which is the worst placement algorithm? Answers: a) Next fit b) Best fit 3. Probability of getting hole of bigger size after allocating memory to a process is high in: 3 Answers: a) First fit b) Best fit c) Worst fit d) Probability is same in all 4. Let there be N block in memory. So in multiprogramming environment the degree of multiprogramming is bounded by: 4 Answers: a) N-1 b) N/2 N+1 d) N 5. External fragmentation is caused mainly by: Answers: a) Worst-fit and Best-fit d) None of the above. 5 c) b) First-fit and Worst-fit c) First-fit & Best-fit

Links for further reading Reference websites: Books: Operating Systems Internals & Design Principles-William Stallings.

Links for further reading Reference websites: Books: Operating Systems Internals & Design Principles-William Stallings. Operating System Concepts- Silberschatz, Galvin, Gagne. Modern Operating Systems- Andrew S. Tanenbaum. Research papers:

Summary: 1. 1. Best Fit: In this algorithm, closest minimum available memory block is

Summary: 1. 1. Best Fit: In this algorithm, closest minimum available memory block is allocated to process. Worst Fit: In this concept, maximum available memory is allocated to the process demanding for it. Thus, it is logically contrasting to best fit algorithm. Next Fit: In this algorithm, memory is scanned from current location for next available block that has sufficient space to accommodate it. 1. Worst-fit algorithm is the best placement algorithm because it results in less amount of fragmentation. 1. Best-fit is the worst placement algorithm because it scans the entire memory space resulting in more time