OS Signaling Assignment | Buy Assignments Online

In this project, we are to simulate a time-sharing system by using signals and timers. The data structure and worker thread have been well implemented with semaphore. You will focus on implementing the scheduling algorithm (Round Robin). Assuming we can not change actual “time slices” in OS we use interval timers to model it.  The scheduler is installed with an interval timer. The timer starts ticking when the scheduler picks a thread to use the CPU which in turn signals the thread when its time slice is finished thus allowing the scheduler to pick another thread and so on. When a thread has completely finished its work it leaves the scheduler to allow a waiting thread to enter. Please note that in this project, only the timer and scheduler send signals. The threads passively handle the signals without signaling back to the scheduler.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

The goal of this project is to help you understand (1) how signals and timers work, and (2) how to evaluate the performance of your program. (3) understand how the POSIX:TMR interval timer works. You will first implement the time-sharing system using timers and signals. Then, you will evaluate the overall performance of your program by keeping track of how long each thread is idle, running, etc.

The program takes a number of arguments. Arg1 determines the number of jobs

(threads in our implementation) created; arg2 specifies the queue size of the

scheduler. Arg3 through argN gives the duration (the required time slices to

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

complete a job) of each job. Hence if we create 2 jobs, we should supply arg3

and arg4 for the required duration. You can assume that the autograder will

always supply the correct number of arguments and hence you do not have to

detect invalid input.

professional writing services near me

The program will use these four signals:

SIGALRM: sent by the timer to the scheduler, to indicate another time

quantum has passed.

SIGUSR1: sent by the scheduler to a worker, to tell it to suspend.

SIGUSR2: sent by the scheduler to a suspended worker, to tell it to resume.

SIGTERM: sent by the scheduler to a worker, to tell it to cancel.

All code that does this will be in scheduler.c.

Part I:Modify the scheduler code

———————————————–

The start code uses the scheduler thread to setup the timer and handle the scheduling for the

system. The scheduler handles the SIGALRM events that come from the timer, and

sends out signals to the worker threads.

The starting code has initialized the scheduler with a POSIX:TMR interval timer in init_sched_queue() function in scheduler.c. CLOCK_REALTIME is used in timer_create().

The timer will be stored in the global variable “timer”, which will be started

in scheduler_run().

sigaction() is used in setup_sig_handlers() to install signal handlers for

SIGALRM, SIGUSR1, and SIGTERM. SIGALRM triggers timer_handler(), SIGUSR1

triggers suspend_thread(), and SIGTERM triggers cancel_thread(). Notice no handler is installed for SIGUSR2; this signal will be handled differently, in worker.c which handles the signals from the scheduler.

start_worker() in worker.c immediately suspends the thread, waiting for a resume signal from the scheduler ((1) block SIGUSR2 and SIGALRM, and (2) unblock SIGUSR1

and SIGTERM). sigwait() is used in suspend_thread() to force the thread to suspend itself based on the SIGUSR1 signal and wait for a resume signal (SIGUSR2).

Step 1. (5 pt)

In the scheduler_run() function, start the timer. Use timer_settime().  The

time quantum (2 second) is given in scheduler.h. The timer should go off

repeatedly at regular intervals defined by the timer quantum.

In Round-Robin, whenever the timer goes off, the scheduler suspends the

currently running thread, and tells the next thread to resume its operations

using signals. These steps are listed in timer_handler(), which is called every

time the timer goes off.  In this implementation, the timer handler makes use of

suspend_worker() and resume_worker() to accomplush these steps.

Step 2. (5 pt)

Complete the suspend_worker() function.  First, update the info->quanta value.

This is the number of quanta that remain for this thread to execute.  It is

initialized to the value passed on the command line, and decreases as the thread

executes.  If there is any more work for this worker to do, send it a signal to

suspend, and update the scheduler queue. Otherwise, cancel the thread.

Step 3. (5 pt)

Complete the cancel_worker() function by sending the appropriate signal to the

thread, telling it to kill itself.

Step 4. (5 pt)

Complete the resume_worker() function by sending the appropriate signal to the

thread, telling it to resume execution.

Part II:Modify the evaluation code

————————————————–

This program keeps track of run time, and wait time. Each thread saves these

two values regarding its own execution in its thread_info_t.  Tracking these

values requires also knowing the last time the thread suspended or resumed.

Therefore, these two values are also kept in thread_info_t.  See scheduler.h.

You will implement the functions that calculate run time and

wait time. When the program is done, it will collect all these values, and print out the total and average wait time and run time. For your convenience, you are given a function

time_difference() to compute the difference between two times in microseconds.

Step 5. (5 pt)

Modify create_workers() to initialize the various time variables.

Step 6. (5 pt)

Implement update_run_time().  This is called by suspend_worker().

Step 7. (5 pt)

Implement update_wait_time().  This is called by resume_worker().

Step 8. (15 pt)

Test your code with 4 worker threads with queue size 2. You can set quanta yourself. Your result should show the statistics at the last lines.

Output:

Here is an example of program output, once the program is complete:

Sample Output

Sample Output Part 2

Tips:

  1. Make file is provided.
  2. You will use these functions (not limited to):

pthread_kill

timer_settime

clock_gettime

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with Homework Writing Services
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
Testimonials
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Leadership Studies
excellent job
Customer 456821, July 30th, 2022
Other
Good work.
Customer 455119, May 27th, 2022
Automotive
Excellent writing.
Customer 452441, April 26th, 2022
Healthcare & Medical
Thank You for such a great content
Customer 463469, October 29th, 2022
Finance/Acc related
Outstanding discussion, grammar, and plagiarism score.
Customer 460073, April 6th, 2022
Sociology
Really beautiful, beautiful work here. Well done! I love this service so much!
Customer 454259, April 11th, 2020
Classic English Literature
Good work.
Customer 460021, June 3rd, 2022
Management
Excellent. Thank you. I am grateful and I am thankful. I hope you have a wonderful day :)
Customer 454227, May 10th, 2020
Retail
Great services
Customer 463473, November 10th, 2022
History
Good work.
Customer 463049, June 5th, 2022
Healthcare & Medical
Great work.
Customer 452441, May 11th, 2022
Nursing
Thank you for your promptness
Customer 453627, January 23rd, 2020
11,595
Customer reviews in total
96%
Current satisfaction rate
3 pages
Average paper length
37%
Customers referred by a friend
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat