Ask Operating System Expert

Assignment

Multiple-Processor Scheduling Simulation

The goal of this simulation is to give you some experiences using POSIX Pthreads library functions for thread creations and synchronizations. You will learn how to solve the critical section problems using pthread_mutex_lock(),  pthread_mutex_unlock(), pthread_cond_wait(), and pthread_cond_signal().

Write a program scheduler in C under Linux environment to simulate the operations of 3-Processor Scheduling Simulation. The programs for this simulator should include the following features:

1) There is one Ready-Queue, where the processes are waiting for three CPUs, CPU-1, CPU-2, and CPU-3. Assume that initially the queue is empty, and all CPUs are waiting for the processes. Assume the queue has capacity only for m processes.

2) Each CPU is waiting for processes arriving in the queue. The arrival of a process (to the queue) should interrupt any of the waiting CPUs, which will grab the process, and execute it. Use pthread_cond_wait( ) and pthread_cond_signal( ) functions to simulate this step.

3) Assume that a job list is stored in a file, job_file. A job in the file is represented as:

job#  cpu_burst

where job# is a positive integer, and the cpu_burst is another positive integer (in second). Note that, each  job may have different  cpu_burst. Create yourself the job_file that contains 200 jobs with random cpu_burst (1 to 50).

4) Write a routine  job() that takes jobs from the  job_file and puts them into the FIFO Ready_Queue. For each job placed in the queue, the job()  routine should write this activity into a file, simulation_log.

Job#: cpu_burst

Arrival time: 13:42:51

where the arrival time is the time the job is placed into the queue (actual time).

5) Write a routine cpu() that simulates the operations of each CPU. When there is process in the queue, one of the CPUs takes the process from the queue, and executes it for its entire cpu_burst. Simulate this event, for example, using a sleep call.

6) When CPU-1, for example, takes one process from the queue, the CPU should write the following information in the simulation_log:

Statistics for CPU-1:

Process #n

Arrival time: 13:42:55

Service time: 13:42:57

The service time is the time the CPU picked up the process from the queue. Notice that the process's waiting time is its service time minus arrival time.

7) When  CPU-1, for example, finishes with one process, the CPU should write the following information in the simulation_log:

Statistics for CPU-1:

Process #n

Arrival time: 13:42:55

Completion time: 13:42:57

where the completion time is the time when the CPU finished servicing the process #n. Notice that the process's turnaround time is its completion time minus its arrival time.

8) The simulator terminates when there is no more process (NOT when the queue is empty). The simulator should write the following information to the log file:

Number of processes: #of processes

Average waiting time: w seconds

Average turn around time: t seconds

where #of processes is the total processes serviced by the 3 CPUs. The average waiting time, and turn around time are computed by dividing the total waiting time and turn around time with #of processes over all the three CPUs, respectively. Note that you may have variables num_processes, total_waiting_time and total_turnaround_time shared by the three CPUs.

9) Note, the assignment does not require high degree of precision for the time.

10) To test for the correctness of your program, you should run the program as follows:

scheduler job_file m

Implementation using Pthreads

1. Create a thread job that runs the job() routine, and three threads CPU-1, CPU-2, and CPU-3 each runs the cpu()  routine. Each CPU thread blocks when the ready queue is empty, and job thread blocks when the queue is full.

Use pthread mutual exclusion functions, pthread_mutex_wait(), pthread_mutex_signal(), pthread_cond_wait(), and pthread_cond_signal() to solve the critical section and synchronization problems in the simulator. Make sure you consider all possible race conditions in the simulator.

3. You have to describe/discuss in detail each of the variables, including its data structure, the threads that access them, and how mutual exclusion is achieved.

4. Remember to clean up all resources created in your program.

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M91966914

Have any Question?


Related Questions in Operating System

Research types of operating systems that are currently

Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Explain why you think the choice you made ...

Question research hex editors available for mac os and

Question : Research hex editors available for Mac OS and Linux. Based on the documentation, how easy would validating these tools be? Select at least two hex editors for each OS, and discuss what you would do to validate ...

Foundation of information technologyresearch types of

Foundation of Information Technology Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Expl ...

Assignment -building a multi-threaded web server using c

Assignment - Building a multi-threaded web server using C and p threads, following the model from the lecture. Your program will have one thread acting as a dispatcher thread, listening fornetwork connections with reques ...

Question you are a security administrator responsible for

Question: You are a security administrator responsible for providing secure configuration requirements for new laptop deployments. After reading Module 2 of Certified Secure Computer User v2exercises, apply the configura ...

Question what do you see as the major differences between

Question : What do you see as the major differences between UNIX/Linux and other operating systems, such as Windows and Mac OS X? The response must be typed, single spaced, must be in times new roman font (size 12) and m ...

Question description of lasa in this assignment you will

Question: Description of LASA: In this assignment, you will select a real-world operating system (can be for a PC, server, tablet, handheld, or embedded device). You will introduce the operating system and its components ...

Discussion question this research assignment will give

Discussion Question : This research assignment will give further information on the nature and workings of multi-tasking and multi-processing operating systems. All information reported in this assignment is to be in the ...

Taskyour job in this assignment is to create two virtual

Task Your job in this assignment is to create two Virtual machines each running a different but the latest distribution of Linux e.g. Ubuntu Server and CentOS. Each of these VM's is to offer services to a user base. The ...

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Briefly describe the following concepts and indicate how they are related in the context ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As