Answer the following questions:

1. Including the initial parent process, how many processes are created by the following process? Explain in few lines.
#include <stdio.h>
Int main()
/*fork a child process */
/*fork another child process */
/*fork a child process */
return 0;

2. Consider the following code segment:
pid pid;
pid =fork();
if (pid == 0) {/*child process */
a. How many unique processes are created?
b. How many unique threads are created?

3. Design a program using ordinary pipes in which one process sends a string message to a second process, and the second process reverses the case of each character in the message and sends back to the first process. For example, if the first process sends the message Hello, the second process will return olleh. This will require using two pipes, one for sending the original message from the first to the second process and other for sending the modified message from the second to the first process. Write it using UNIX pipes.

4. Write a program in C language for server and client, client should get date from server and client displays it, it should be done using socket.

5. A multithreaded web server wishes to keep track of the number of requests it services (known as hits). Consider the two following strategies to prevent a race condition on the variable hits. The first strategy is to use a basic mutex lock when updating hits:
int hits;
mutex_lock hit_lock;
A second strategy is to use an atomic integer:
atomic_t hits;
Explain which of these two strategies is more efficient.

6. Race conditions are possible in many computer systems. Consider a banking system that maintains an account balance with two functions: deposit (amount) and withdraw (amount). These two functions pass the amount that is to be deposited or withdrawn from the bank account . Assume that a husband and wife share a bank account. Concurrently, the husband calls the withdraw () function and the wife calls deposit (). Describe how a race condition is possible and what might be done to prevent the race condition from occurring.

7. Suppose that the following processes arrive for execution at the times indicated. Each process will run for the amount of time listed. In answering the questions, use nonpreemptive scheduling, and base all decisions on the information you have at the time the decision must be made.
a. What is the average turnaround time for these processes with the FCFS scheduling algorithm?
b. What is the average turnaround time for these processes with the SJF scheduling algorithm?
c. The SJF algorithm is supposed to improve performance, but notice that we chose to run process P1 at time 0 because we did not know that two shorter processes would arrive soon. Compute what the average turnaround time will be if the CPU is left idle for the first 1 unit and then SJF scheduling is used. Remember that processes P1 and P2 are waiting during this idle time, so their waiting time may increase. This algorithm could be called future-knowledge scheduling.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

A total of 8 processes are created by the script.
The process forks at each fork(), thus not only does the original parent process fork but also its child processes. That is, since at at each fork() the number of existing processes is doubled, a total of 2 to the
power of 3 processes result.

6 unique processes are created; the parent is forked (2), and the child is forked yet again (1+2=3). All processes are forked again (3*2=6).

8 unique threads are created. All unique processes are threads themselves (6), additionally, off the original process the child is forked; an additional thread is created, for each of the two (6+2=8)....
$39.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Linux Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats