Part 1. Mark True or False for each of the following questions. (40 points)
eg) Operating
systems execute user programs and make solving user problems easier. True
1. Handheld
device operating systems are designed primarily to maximize resource
utilization.
False
---
2. A process
control block (PCB) contains CPU usage and clock time elapsed since start.
False --- true
3. Privileged
instructions can run in any of the dual modes user mode and kernel mode.
False
can be done only in kernel mode
4.
Multiprogramming operating systems is designed to improve response time for
multiple users.
True
-- false
5. Data section of process in memory contains
function parameters, return addresses, local variables
False
6. Dual mode of
operating in a system consists of logical mode and physical mode.
False
7. Threads
inside a process share global variables.
True
8. Parent can
access its child process’ global variables.
9. Onetoone mapping between user thread and
kernel thread provides more concurrency than manytoone mapping.
True
10. A race condition may result from multiple
processes trying to read the same data concurrently.
True
Part 2 (1113).
Please answer to the following questions. (40 points)
11. Suppose
a husband and a wife are accessing the same bank account they share. The current balance is $100. The husband
tries to deposit $100 to the account
while the wife tries to withdraw $50 from
the account at the same time. Assuming those transactions are not atomic and no
mutual exclusion is used for transactions, list all the possible values of the
final balance. Explain briefly how each value is possible.
(20 points)
12. Message passing may be either blocking
(synchronous) or nonblocking (asynchronous). Please explain briefly how the
followings work. (10 points)
(a) Blocking
send
(b) Nonblocking send
(c) Blocking
receive
(d) Nonblocking receive
13. Solutions
to critical section problems are required to satisfy the following conditions
mutual exclusion
progress
bounded waiting
Please explain
briefly about the requirement “bounded
waiting”. (10 points)
Part 3 (1415).
Check out the programs and answer to questions. (30 points)
14. Assuming every fork() succeeds, what output
will be displayed on the screen? Note that each process display one line so
there will be as many lines of output as there are processes. The order of
processes’ output doesn’t matter. (15 points)
int value = 0;
int main()
{
pid_t pid; int i;
pid = fork();
if(pid == 0) {
value = value + 10 ;
pid = fork();
}
fork();
printf(“value=%d\n”, value);
return 0;
}
15. Many modern computer systems provide special
hardware instructions that allow us either to test and modify the content of a
word or to swap the contents of two words atomically.
The following shows the hardware instruction compare_and_swap()and to use
it in a code to solve a critical section problem.
int compare_and_swap(int *value, int expected, int new_value) {
int temp = *value;
if (*value == expected)
*value = new_value;
return temp;
}
int lock = 0;
int main(){
...
while
(compare_and_swap(&lock, 1, 0) != 0)
/* Line P */
; /* do nothing */
/* critical section */
lock = 0;
/* remainder section */
}
But the above code does not provide mutual
exclusion properly. Fix the problem by rewriting line P. (15 points)
while(
)
/* Line P */
Thanks for providing the answers!
ReplyDeletecan u share the answers
DeleteThis comment has been removed by the author.
ReplyDeleteCan you share answers
ReplyDelete