Create a thread job that runs the job routine

Assignment Help Operating System
Reference no: EM131210910

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.

Reference no: EM131210910

Questions Cloud

The logic of the heckscher ohlin theory : According to the logic of the Heckscher-Ohlin theory, why is the shape of the U.S. production-possibility curve different from the shape of the production-possibility curve for the rest of the world?
Why this assumption is required and extend the idea : Explain why this assumption is required and extend the idea to cover the case of variable length records.
Estimate the number of days : If daily water demand is approximately normally distributed with a mean of 5 ml and a standard deviation of 1.25ml: Estimate the number of days in a (365 day) year on which daily consumption is:
Approximately normal with equal variances : Construct a 95 % confidence interval for μ1-μ2 with the sample statistics for mean calorie content of twobakeries' specialty pies and confidence interval construction formula below. Assume the populations are approximately normal with equal varia..
Create a thread job that runs the job routine : 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
What is the purpose served by foundations : What is the purpose served by foundations? What is a column? What kinds of forces are a column subjected? What is a beam? What building elements typically support beams?
Define the term most selective access path for a query : Suppose that you are building a DBMS and want to add a new aggregate operator called SECOND LARGEST, which is a variation of the MAX operator. Describe how you would implement it.
Sampling distribution of the sample : Suppose the population proportion is 0.60. If the sample size is equal to 20, what is the sampling distribution of the sample proportion, 'p-hat'?
Compute the mean and standard deviation : Compute the mean and standard deviation of the hourly wages.

Reviews

Write a Review

Operating System Questions & Answers

  Describe benefits of providing synchronization tool

Slim reader-writer locks favor neither readers nor writers, nor are waiting threads ordered in FIFO queue. Describe benefits of providing such a synchronization tool.

  Design and implement demand paging virtual memory simulator

Design and implement a Demand Paging virtual memory simulator! It must be a text based application (NOT a GUI based one). You can use the C/C++ or Java programming language

  Virtual machine design where guest operating systems are

virtual machine design where guest operating systems are independent virtual machines supported by a host operating

  Compare physical access controls and logical access controls

Compare and contrast physical access controls and logical access controls. Further explain in what ways both physical and logical access controls are related to implementing a security policy.

  How could you copy all the files from the current directory

How could you move all the files that end with an extension *.h in your home directory to the current directory without knowing the full path to the current directory [Hint: use a shortcut for the home directory and current directory.

  A typist is entering text on a keyboard

A typist is entering text on a keyboard at the rate of 30 words per minute. If each word is 6 characters long on average, how many bits per second are being sent to main memory? A space is also a character. Assume that each word is followed by one sp..

  Eight servers running red hat linux

There are eight servers running Red Hat Linux (RHL) 7.3 and two running RHL 8.0.At this point, the two servers running version 8.0 are only test servers.

  Advantage of modularizing code

Imagine you are a part of a team that is tasked with writing a mobile application (app) that will allow users to send pictures to their friends. The manager does not want to waste time creating code modules. Describe at least one (1) advantage of ..

  Identify a trend that could influence the development

Identify a trend that could influence the development of future operating systems

  Most of the operating systems use a virtual memory manager

most operating systems use a virtual memory manager vmm whose responsibility is to manage the relationship between the

  Propose a design for the implementation of client operating

You are the Chief Information Officer (CIO) of a medium sized business that provides an online data base to Internet subscribers. By then end of the current business quarter, you must propose a design for the implementation of client operating sy..

  Modify the payroll program application

Modify the Payroll Program application so it continues to request employee information until the user enters stop as the employee name

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd