Question

Operating System a. What is the meaning of the term busy waiting? What other kinds of...

Operating System a. What is the meaning of the term busy waiting? What other kinds of waiting are there in an operating system? Can busy waiting be avoided altogether? Explain your answers. (5 pts) b. Explain why spinlocks are not appropriate for single-processor systems yet are often used in multiprocessor systems. (5 pts) c. Using the program shown below, explain what the output will be at lines X and Y. Assume that you have a pre-emptive priority system. (10 pts) #include #include #inculde #define SIZE 5 int nums[SIZE] = {0,1,2,3,4}; int main() { int i; pid_t pid; pid = fork(); if (pid ==0) { for (i =0; i < SIZE; i++) { nums[i] *= -i; printf(“CHILD: %d “,nums[i]); /*LINE X */ } } else if (pid > 0) { wait (NULL); for (i = 0; i < SIZE; i++) printf(“PARENT: %d “,nums[i]); /* LINE Y */ } return 0; } Part2 Consider a system with 3 physical frames of memory that is given the following page memory reference sequence (20 pts): 1, 3, 6, 7, 1, 3, 6, 7, 1, 3, 6, 7 What is the number of page faults that would occur for each of the following page replacement algorithms? a. An optimal page replacement algorithm (7 pts) b. LRU (7 pts) c. Does an optimal page replacement algorithm exist that does not require future knowledge for cyclical memory reference sequences such as shown above? If so, give a general algorithm. If not, explain why. (6 pts) 1) Consider a machine with a physical memory of 8 GB, a page size of 8 KB, and a page table entry size of 4 bytes. How many levels of page tables would be required to map a 46-bit virtual address space if every page table fits into a single page? Be explicit in your explanation. (5 points) 2) List the fields of a Page Table Entry in your scheme. (5 points) 3) Without a cache or TLB, how many memory operations are required to read or write a single 32-bit word? (5 points) 4) How much physical memory is needed for a process with three pages of virtual memory (for example, one code, one data, and one stack page)? (5 points)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Basically busy waiting is a scenario when a process looks for a condition repeatedly so it is busy to check the condition as well as it is waiting for it in this way a process will be in busy waiting condition. In other hand we can say when the processor is doing nothing but spending its clock cycle continuously and waiting for some event occurrence then the scenario will be called as busy waiting.

Busy waiting can't be avoided altogether. But some time it can be avoided but it will incurs some associated overhead like putting the process in sleep and wake up.

b). Implementing synchronisation primitive by disabling interrupt is not appropriate for single processor system because if a user level program will be able to disable interrupt then it can disable the timer interrupt also which will effect the context switching.

A semaphore can be initialized to the socket connection which is allowable. When connection is accepting accquire() will be called and after releasing the connection relese() will be called. If the system will reach the highest number of allowable connections then it will block the acquire() method until Atleast one connection is released.

c)

#include <sys/types.h>

#include <stdio.h>

#include <unistd.h>

#define SIZE 5

int nums[SIZE] = {0,1,2,3,4};

int main()

{

1. int i;

2. pid t pid;

3. pid = fork();

4. if (pid == 0) {

5. for (i = 0; i < SIZE; i++) {

6. nums[i] *= -i;

7. printf("CHILD: %d ",nums[i]); /* LINE X */

8. }

9. }

10. else if (pid > 0) {

11. wait(NULL);

12. for (i = 0; i < SIZE; i++)

13. printf("PARENT: %d ",nums[i]); /* LINE Y */

14. }

15. return 0;

16. }

Figure 3.35 What output will be at Line X and Line Y?

As per the same logic which we discussed in problem 1, the line 4 will be evaluated to true by the child process, and the lines 5,6,7,8 will be executed by the child process. The line 10 will be evaluated to true by the parent process, and the lines 11,12,13 will be executed by the parent process.

Initially nums[5] = {0,1,2,3,4}.

The same values will be passed to the child process.

By child process:

Line 5: It indicates that the loop (line 6, and line 7) will be evaluated for 5 times, for different values of i:

i = 0: nums[0] = nums[0] * -i.

  • nums[0] = 0 * 0. /*0 will be printed*/

i = 1: nums[1] = nums[1] * -i.

  • nums[1] = 1 * -1. /*-1 will be printed*/

i = 2: nums[2] = nums[2] * -i.

  • nums[2] = 2 * -2. /*-4 will be printed*/

i = 3: nums[3] = nums[3] * -i.

  • nums[3] = 3 * -3. /*-9 will be printed*/

i = 4: nums[4] = nums[4] * -i.

  • nums[4] = 4 * -4. /*-16 will be printed*/

Therefore at Line X the output will be:

CHILD: 0 CHILD: -1 CHILD: -4 CHILD: -9 CHILD: -16

By parent process:

Line 10: It indicates that the loop (line 12, and line 13) will be evaluated for 5 times, after waiting the wait(NULL) system call once.

The wait() system call is used to wait for state changes in a child of the calling process, and obtain information about the child whose state has changed. That means this loop will wait till the child process finishes its execution.

After that, the loop will be evaluated, for different values of i:

i = 0: nums[0] value is 0.

i = 1: nums[1] value is 1.

i = 2: nums[2] value is 2.

i = 3: nums[3] value is 3.

i = 4: nums[4] value is 4.

Therefore at Line Y the output will be:

PARENT: 0 PARENT: 1 PARENT: 2 PARENT: 3 PARENT: 4

part 2:

a).

Table size=page size=2^13
Physical memory=2^33
Virtual address space=46 bit
Page entry size=4 bytes


So tolat entry in a page=page size/page entry size => VPN(Virtual Page no)=11 bit long

page offset=13 bit (as page size is 2^13)

So it can be devided only in this way=(11+11+11)+13
So, It should be a three level paging.

Add a comment
Know the answer?
Add Answer to:
Operating System a. What is the meaning of the term busy waiting? What other kinds of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Problem 6 (13 points) The page table below is for a system with 16-bit virtual as well as physica...

    Problem 6 (13 points) The page table below is for a system with 16-bit virtual as well as physical addresses and with 4,096-byte pages. The reference bit is set to 1 when the page has been referenced. Periodically, a thread zeroes out all values of the reference bit. A dash for a page frame indicates the page is not in memory. The LRll pagg-replacement algorithm is used. The numbers are given in decimal Page Frame eferepceit 14 10 13 15...

  • Problem 6 (13 points) The page table below is for a system with 16-bit virtual as...

    Problem 6 (13 points) The page table below is for a system with 16-bit virtual as well as physical addresses and with 4,096-byte pages. The reference bit is set to 1 when the page has been referenced. Periodically, a thread zeroes out all values of the reference bit. A dash for a page frame indicates the page is not in memory. The LRll pagg-replacement algorithm is used. The numbers are given in decimal Page Frame eferepceit 14 10 13 15...

  • 3. Virtual Memory (20 points) An ISA supports an 8 bit, byte-addressable virtual address space. The...

    3. Virtual Memory (20 points) An ISA supports an 8 bit, byte-addressable virtual address space. The corresponding physical memory has only 256 bytes. Each page contains 32 bytes. A simple, one-level translation scheme is used and the page table resides in physical memory. The initial contents of the frames of physical memory are shown below. VALUE address size 8 bit byte addressable each byte of addressing type memory has its own address 32 B page size physical memory size 256...

  • Operating Systems Questions (Please help if you can) 1. A computer has cache, main memory, and...

    Operating Systems Questions (Please help if you can) 1. A computer has cache, main memory, and a disk used for virtual memory. If a referenced word is in the cache, 20ns are required to access it. If it is in main memory but not in the cache, 60ns are required to load it into the cache (this includes the time to originally check the cache), and then, the reference is started again. If the word is not in main memory,...

  • Name Olbinna COSC414/514 Quiz3 (1) Suppose a computer has 4 physical pages, and a process referen...

    Name Olbinna COSC414/514 Quiz3 (1) Suppose a computer has 4 physical pages, and a process references its virtual pages (page o through page 7) in the following order: 021354637473355311172341 Also suppose the first four pages have been loaded in the physical memory as the following figure: Frame 0 Frame 1 Frame 2 Frame 3 a. Suppose the kernel uses First-In-First-Out (FIFO) page replacement algorithm. How many page faults would the process have? Which page references are page faults? b. Suppose...

  • D | Question 1 7.14 pts 57 Minutes. 29 Secon What causes the VM subsystem to...

    D | Question 1 7.14 pts 57 Minutes. 29 Secon What causes the VM subsystem to handle a page fault? 0 the M?U translates wrtual address and determines the page numbers beyond the page table length register's value the process attempts to exeoute this code 100. O the MMU translates a virtual address and whenit reads the page entry from the pare tables finds the vald/invalid bit to be imalid and thus trisgers a pae fault exception O the process...

  • Consider the page table shown below for a system with 16-bit virtual and physical addresses and...

    Consider the page table shown below for a system with 16-bit virtual and physical addresses and with 4096-byte pages. All numbers below are given in hexadecimal. (A dash for a page frame indicates that the page is not in memory.) Page Number Physical Frame Number 0 - 1 2 2 C 3 A 4 - 5 4 6 3 7 - 8 B 9 0 Convert the following virtual addresses to their equivalent physical addresses in hexadecimal. a) 9EF5 b)...

  • SN 6 A system implements a paged virtual address space for each process using a one-level...

    SN 6 A system implements a paged virtual address space for each process using a one-level page table. The maximum size of virtual address space is 4KB. The page table for the running process Includes the following valid entries: Virtual Virtual page 7 - Page frame 4 Virtual Virtual page 5 - Page frame 0 Virtual Virtual page 20 - Page frame 1 Virtual Virtual page 10 - Page frame 3 Virtual Virtual page 3 - Page frame 2 The...

  • Assume you have: 32-bit addresses, 4KB Page size, 4MB Physical Memory Space, 4KB Cache with 4-way...

    Assume you have: 32-bit addresses, 4KB Page size, 4MB Physical Memory Space, 4KB Cache with 4-way set associative and LRU replacement, 32 Byte Cache block size, 4-entry fully associative TLB. A program to be run on this machine begins as follows:   double A[1024]; int i, j; double sum = 0; for( i = 0; i < 1024; i++ )       // first loop      A[i] = i; for( j = 0; j < 1024; j += 16 )   // second loop     ...

  • Implement the frame replacement algorithm for virtual memory Assume a computer system have 10 memory frames available inside the physical memory and is required to execute a process containing 20 pa...

    Implement the frame replacement algorithm for virtual memory Assume a computer system have 10 memory frames available inside the physical memory and is required to execute a process containing 20 pages. Assume a process P has been executed in the system and produced a sequence of 40 page demands as follows: Page demands trace of process P Demand 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 cont. Page...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT