Digital Academic Solutions

Introduction to Operating Systems: Random Question/Answers

Chapter-3

Question: Let’s say a program has 510 bytes and will be loaded into page frames of 256 bytes each, and the instruction to be used is at byte 377, answer the following questions:

  • How many pages are needed to store the entire job?
    Answer: The number of pages required = total length of program/page size = 510/256 = 1.99. Therefore, number of pages needed to store the program = 2.
  • Compute the page number and exact displacement for each of the byte addresses where the data is stored.
    Answer: The first page commences from address 0. As the given page size is 256 bytes each: Address 256 represents page 1 (the second page) with offset (displacement) 0. Address 266 represents page 1with offset 1. Address 514 represents page 2 with offset 2.

Question: Given that main memory is composed of only three page frames for public use and that a seven-page program (with pages a, b, c, d, e, f, g) that requests pages in the following order: a, c, a, b, a, d, a, c, b, d, e, f

  • Using the FIFO page removal algorithm, indicate the movement of the pages into and out of the available page frames (called a page trace analysis) indicating each page fault with an asterisk (*). Then compute the failure and success ratios.
    Answer: The job pages are (a, b, c, d, e, f) are a total of 6 in number. Also, number of page frames = 3. Therefore, total number of requested pages = 12. (The first-in page, the oldest swappable page, is shown in bold.)
Page request a c a b a d a c b d e F
Page fault * *   *   * * * * * * *
Page Frame 1 a a a a a d d d b b b f
Page Frame 2   c c c c c a a a d d d
Page Frame 3       b b b b c c c e E

Failure ratio = 10 / 12 = 83%

Success ratio = 2 / 12 = 17

  • Increase the size of memory so it contains four page frames for public use. Using the same page requests as above and FIFO, do another page trace analysis and compute the failure and success ratios.

Answer: Here, the number of page frames is increased to 4.

Page request a c a b a d a c b d e F
Page fault * *   *   *         * *
Page Frame 1 a a a a a a a a a a e e
Page Frame 2   c c c c c c c c c c f
Page Frame 3       b b b b b b b b b
Page Frame 4           d d d d d d d

Failure ratio = 6 / 12 = 50%

Success ratio = 6 / 12 = 50%

  • What general statement can you make from this example? Explain your answer.
    Answer: When the size of the main memory is increased by one more page, it enhances the performance to 50%. This, by itself, balances the success-failure ratio. In case the program had a comparatively smaller working set, the number of page faults would have got more effectively reduced and a greater amount of improvement would have been achieved in the performance of the program. The optimal number of job pages for this program is 4.

Question: Given that main memory is composed of only three page frames for public use and that a program requests pages in the following order: a, c, b, d, a, c, e, a, c, b, d, e

  • Using the FIFO page removal algorithm, indicate the movement of the pages into and out of the available page frames (called a page trace analysis) indicating each page fault with an asterisk (*). Then compute the failure and success ratios.
    Answer: The number of page frames is 3 and the job pages are (a, b, c, d, e). The number of job pages = 5. The requested page arrangement is (a, c, b, d, a, c, e, a, c, b, d, e). Therefore, Total number Page Requested are 12. (The first-in page, the oldest swappable page, is shown in bold.)
Page request a C b d a c e a c b d e
Page fault * * * * * * *     * *  
Page Frame 1 a A a d d d e e e e e e
Page Frame 2   C c c a a a a a b b b
Page Frame 3     b b b c c c c c d d

Failure ratio = 9 / 12 = 75%

Success ratio = 3 / 12 = 25%

  • Increase the size of memory so it contains four page frames for public use. Using the same page requests as above and FIFO, do another page trace analysis and compute the failure and success ratios.

Answer: The number of page frames is increased to 4.

Page request a c b d a c e a c b d e
Page fault * * * *     * * * * * *
Page Frame 1 a a a a a a e e e e d d
Page Frame 2   C c c c c c a a a a e
Page Frame 3     b b b b b b c c c c
Page Frame 4       d d d d d d b b b

Failure ratio = 10 / 12 = 83%

Success ratio = 2 / 12 = 17%

  • What general statement can you make from this example? Explain your answer.
    Answer: With the introduction of one more page, the failure ratio topped 83% from the earlier 75%. This means a decrease of 8% in performance. If the working set for this program consisted only of 4 pages, the number of page faults could be significantly reduced.

 

Chapter-4
Question: Five jobs arrive nearly simultaneously for processing and their estimated CPU cycles are, respectively: Job A = 12, Job B = 2, Job C = 15, Job D = 7, and Job E = 3 ms.
a. Using FCFS, and assuming the difference in arrival time is negligible, in what order would they be processed? What is the total time required to process all five jobs? What is the average turnaround time for all five jobs?

Answer: The order of processing for the given jobs = A->B->C->D->E.

Total time needed to process all the jobs = 12+2+15+7+3 = 39 ms.

Turn around time for job A = 12 ms.

Turn around time for job B = 15 ms.

Turn around time for job C = 30 ms.

Turn around time for job D = 37 ms.

Turn around time for job E = 40 ms.

Therefore, the average turnaround time = (12+15+30+37+40)/5 = 26.8 ms.

  • Using SJN, and assuming the difference in arrival time is negligible, in what order would they be processed? What is the total time required to process all five jobs? What is the average turnaround time for all five jobs?

Answer: The order of processing of given jobs will be B->E->D->A->C.

Total time taken to process all the jobs = 12+2+15+7+3 = 39 ms.

Turn around time for job B = 2 ms.

Turn around time for job E = 5 ms.

Turn around time for job D = 12 ms.

Turn around time for job A = 24 ms.

Turn around time for job C = 39 ms.

Therefore, the average turnaround time = (12+15+30+37+40)/5 = 26.8 ms.

Question: Using SJN, calculate the start time and finish time for each of these seven jobs: Job Arrival Time CPU Cycle
A 0 2
B 1 11
C 2 4
D 4 1
E 5 9
F 7 4
G 8 2

Answer:

Process            Arrival Time               Start Time       Work Done

A                     0                                  0                      2

C                     2                                  2                      2

D                     4                                  4                      1

C                     2                                  5                      2

F                      7                                  7                      1

G                     8                                  8                      2

F                      7                                  10                    3

E                      5                                  13                    9

B                     1                                  22                    11

Therefore, the start time and finish time are given as below:

Process   Start time    Finish time

A                     0          2

B                     22        33

C                     2          7

D                     4          5

E                      13        22

F                      7          13

 

Leave a Reply

Your email address will not be published. Required fields are marked *



Solutions Authored by 15+ Years Experienced Industry Experts