Upgrade to Pro — share decks privately, control downloads, hide ads and more …

OPERSYS Oral Exam 3 - Problem 4

OPERSYS Oral Exam 3 - Problem 4

My slides outlining the problem and the solution of the fourth problem in the third oral exam in my OPERSYS course, which I have volunteered to answer in front.

john_mcderp

March 04, 2012
Tweet

Other Decks in Education

Transcript

  1. The Problem Suppose that we have a system with a

    physical memory measuring 700 words (1400 bytes). Additionally, our operating system will be occupying the first 200 words of memory. 700 words 0 700 (Kinda too small)
  2. Job Table Job ID Arrival Time Segments and Sizes Finish

    Time 1 0 S0 – 30 S1 – 20 S2 – 50 11 2 2 S0 – 25 S1 – 85 8 3 3 S0 – 20 S1 – 50 S2 – 70 S3 – 30 12 4 9 S0 – 100 S1 – 35 S2 – 40 14 5 10 S0 – 20 S1 – 10 S2 – 50 S3 – 35 25 6 15 S0 – 200 S1 – 40 30 * Segment Size is expressed in words.
  3. Time 1 J1 - S0 J1 - S1 J1 -

    S2 Foo 0 200 230 250 300 700 What happened here? • J1 arrived at time 0 (system init) • All of J1's segments were allocated into physical memory. • They were allocated into the next memory location after OS to reduce fragmentation.
  4. Time 5 J1 - S0 J1 - S1 J1 -

    S2 J2 - S0 J2 - S1 J3 - S0 J3 - S1 J3 - S2 J3 - S3 Foo 0 200 230 250 300 700 What happened here? • J2 arrived at Time 2. Its first segment was allocated right after J1-S2. • It still followed the “worst fit” policy because the largest hole was the one after segment J1-S2. • J3 arrived at Time 3. Its first segment occupied the memory location right after J2-S1. • The memory allocation of J3 and its segments still followed the “worst fit” policy because the largest hole is the one right after J2-S1. 325 410 430 480 550 580
  5. Time 10 J1 - S0 J1 - S1 J1 -

    S2 J4 - S0 Foo J3 - S0 J3 - S1 J3 - S2 J3 - S3 J4 - S1 J4 - S2 Foo 0 200 230 250 300 700 What happened here? • J2 finished executing at Time 8. Its segments were freed from memory. • J4 arrived at Time 9. Its first segment, J4-S0, was allocated in the first biggest hole it found (after J1- S2). • The rest of the segments could not fit after the first so they were allocated in the free space after J3-S3. • J5 arrived at Time 10, but at that time there wasn't a hole big enough to accommodate all of its segments in memory, so it was forced to wait. (It is not shown here). 400 410 430 480 550 580 615 655
  6. Time 13 J5 - S0 J5 - S1 J5 -

    S2 Foo J4 - S0 Foo J5 - S3 Foo J4 - S1 J4 - S2 Foo 0 200 220 230 280 700 What happened here? • At Time 11, J1 has finished executing, and its segments were freed from memory. • At Time 12, J3 has finished executing, and its segments were freed from memory as well. • After J1 and J3 were freed, there were now holes in the memory big enough for J5 to fit itself and its segments into, so it was allocated into memory. • However, it could not fit contiguously from word 200 to 300, so its last segment, J5 – S3, was allocated at word 410 instead. 300 400 410 445 580 615 655
  7. Time 15 J5 - S0 J5 - S1 J5 -

    S2 Foo J5 - S3 J6 - S0 J6 - S1 Foo 0 200 220 230 280 700 What happened here? • At Time 14, J4 has finished executing, and all its segments were freed from memory. • At Time 15, J6 has arrived, and its segments were allocated into memory. • However, its first segment could not fit in the hole between word 280 to word 410. • Thus, the first segment of J6, J6-S0, was allocated starting from word 445 instead. • Its second segment, J6-S1, followed the last one. 410 445 645 685