1. Homepage
  2. Programming
  3. CPS 590 Operating Systems I - Assignment : Scheduling Algorithms

CPS 590 Operating Systems I - Assignment : Scheduling Algorithms

Engage in a Conversation
CanadaToronto Metropolitan UniversityCPS 590CPS590Operating Systems IScheduling AlgorithmsC

Submissions:

Submit one file at a time using submit-cps590dwoit CourseNana.COM

Only the final submission (Feb 27) is graded. However, it is ineligible for grading (zero) unless the previous 8 files were submitted by their due dates (Feb 20, 23). It is possible that by Feb 20 and/or 23, some of the files might be empty because you haven't worked on that part yet. Nonetheless, STILL SUBMIT the required files (on Feb 20 and 23), even if some (or all) are empty. On Feb 20 and 23 you MUST submit EVERYTHING you have for the assignment so far. CourseNana.COM

YOUR ASSIGNMENT MUST COMPILE AND RUN PROPERLY ON THE MOONS. We suggest you do all your development on the moons. However, if you choose to develop elsewhere, then make sure you download your files to the moons and submit as required by all the required dates. If you're developing elsewhere, don't attempt to download to moons and do your final submission at the last minute. Why? Because your program(s) likely won't compile and/or run as you expect on the moons (because your development environment differs.) If this happens, you likely won't have enough time to debug. CourseNana.COM

Due Dates:

Files are due by 11:59pm on their due dates. Late submissions are not graded. CourseNana.COM

Monday Feb 20: Feb20director.sh Feb20scheduler.c Feb20worker.c Feb20queue.c Feb20queue.h Feb20queueX.h Optional: X is a string of your choice (only necessary if you have more than one .h file) CourseNana.COM

Monday Feb 23: Feb23director.sh Feb23scheduler.c Feb23worker.c Feb23queue.c Feb23queue.h Feb23queueX.h as above, optional. CourseNana.COM

Monday Feb 27 (graded): director.sh scheduler.c scheduler (executable) worker.c worker (executable) queue.c queue.o (object code) queue.h queueX.h as above, optional. CourseNana.COM

The task:

The task is to create exactly W files, with each file containing exactly 40 '*' CourseNana.COM

characters, and nothing else. The task must be accomplished using 3 programs as follows: CourseNana.COM

worker: a C program that creates a file and writes 40 '*' characters into i t. director: a bash shell program to create W worker processes and monitor their progress (each worker writes into a different file). scheduler: a C program to coordinate the W worker processes via some schedulin g algorithm, using one or more queues CourseNana.COM

Details: -no busy-waits are allowed in any program. Instead, use an appropriate functio n from section 2 or 3 of the manual such as: sleep(), pause(), sigsuspend(), sigwai tinfo(), etc. -programs must behave robustly (e.g., do something reasonable when a process i t needs is unexpectedly dead.) -programs must exhibit the behaviors outlined below. CourseNana.COM

director (bash shell program):

The director needs two command-line arguments: W (the number of workers to create) sPID (the process ID of the already-executing scheduler process) CourseNana.COM

The director starts W worker processes to run in background, each with its own file. Then, once per second, forever, director calls a local function named display, which clears the screen, then prints the contents of the W files, in order, on stdout. The director terminates when it receives the SIGINT signal (e.g., ctrl-c from keyboard). The director traps SIGINT so that it may perform "clean-up" before terminating, including making sure the W worker processes are terminated and deleting the W files. See man page for trap. Director must name files something reasonable. Director requires scheduler to be executing already (needs its process ID). CourseNana.COM

worker (C program):

A worker needs 2 command-line arguments: filename (name of its given file) sPID (the process ID of the executing scheduler process) CourseNana.COM

The worker writes 40 '' characters into a its given file, one at a time, one per second. When worker is finished its task, its given file simply contains one long string of '' characters: CourseNana.COM


A worker must not begin writing '*'s until the scheduler signals it may begin. How this happens: CourseNana.COM

  1. The worker sends scheduler a signal to request scheduler include it in the scheduling pool (use an appropriate signal).
  2. The worker waits until it receives some acknowledgement signal from scheduler
    (use something appropriate such as sigstop or sigwaitinfo() ).
  3. When worker receives its acknowledgement signal, it begins writing the '*'s. CourseNana.COM

    When worker has printed all its '*'s, it sends scheduler a signal (to indicate its task is complete), and then it terminates. CourseNana.COM

    Note: the worker does not "know it", but while it's writing '*'s, the scheduler may suspend and resume its execution any number of times. CourseNana.COM

scheduler (C program):

The scheduler needs 3 command-line arguments: W (the number of workers to expect) T (the length of a timeslice (in whatever units you choose) SA (the scheduling algorithm) CourseNana.COM

The scheduler waits for all W workers to request scheduling (via appropriate signals). The scheduler repeats the following until all workers have completed their task: CourseNana.COM

       1. select a worker, w, from among those who are still working at their task 
          (see "Scheduling Algorithm" below) 
       2. allow w to run for its timeslice

The scheduler will send only ONE acknowledgement signal to a given worker. That acknowledgement signal means "you may begin writing your *s". After that, the worker simply works away, and the scheduler takes care of suspending and restarting it. CourseNana.COM

Once all workers have signalled completion of their tasks, scheduler does any necessary "clean up" and terminates. CourseNana.COM

Note that scheduler allows only one worker to execute at a time; the other workers are waiting (non-busy wait). CourseNana.COM

Scheduling Algorithms (Round-Robin and Lucky-7):

The scheduler's third argument indicates the algorithm to use. The only acceptable values are RR (round-robin) or L7 (lucky-seven). Round-robin: Assume workers are "ordered" by the order in which their "request scheduling" signals arrived. When worker i has exhausted its timeslice, the next worker chosen is normally the next one in order, i.e., (i+1) mod W. However, if that next worker has been removed from scheduling (it has completed or has died) the scheduler goes on to the next worker, (i+2) mod W, etc. Implement this round-robin scheduling by making (efficient) use of a circular queue of workers. Lucky-7: Like round-robin, except that the length of the timeslice is doubled for those workers who have a 7 anywhere in the last 4 digits of their process id. (See Timeslices below). CourseNana.COM

Timeslices:

Timeslices are maintained by the scheduler, not by individual workers. The scheduler allows a worker, i, one timeslice as follows: -The scheduler dispatches worker i (via an appropriate signal) -The scheduler does a non-busy wait for one timeslice -When the timeslice is up, scheduler suspends worker i (uses an appropriate signal) CourseNana.COM

queue (C code):

The scheduler requires at least one queue of processes. Implement your queue data structures and operations here. CourseNana.COM

SOME (HOPEFULLY HELPFUL) NOTES: CourseNana.COM

Queuing up signals:

If you find the scheduler is losing some of the worker's "request for scheduling" signals, you might try using a real-time signal instead of a standard signal (since real-time signals are queued up). Some real-time signals are SIGRTMIN, SIGRTMIN+1, etc. CourseNana.COM

To find the signal sender's PID:

One way is, instead of using signal() to set up a signal handler, could use sigaction() with the SA_SIGINFO flag. Then the siginfo_t structure is populated with extra information about the signal, including the sender's PID (in field si_pid). CourseNana.COM

To simply check if a process exists:

Send it signal 0 using kill, and check the return value of kill. From man 2 kill: If sig is 0, then no signal is sent, but error checking is still performed; this can be used to check for the existence of a process ID CourseNana.COM

To send a signal to self:

Can use raise() CourseNana.COM

Some man pages about signals:

man 7 signal man signal.h https://manpages.ubuntu.com/manpages/trusty/man7/signal.h.7posix.html CourseNana.COM

Output buffering:

If you find your output files are blank until the file is closed, it's probably because you are using one of the "printf" family of C functions to write ''s into the file. These may buffer output until the file is closed. The C "fflush" function can help. Note that there are other ways to write ''s into the file that don't cause this exact buffering problem. Use whatever works for you. CourseNana.COM

Testing your code:

The scheduler must be running before the director. You may choose to create your own testing script that starts scheduler, gets its process ID, and then starts the director (sending that process ID). Do not submit it. CourseNana.COM

Error-Checking:

Your programs should be robust. Error-check your program's parameters, regardless. For example, workers should check their arguments, even though they are invoked by the director, presumably correctly. Note that someone/something else may attempt to invoke any of your programs. If arguments are incorrect, your programs should produce appropriate and meaningful error messages. CourseNana.COM

Do Your Own Work:

Do not copy code from other students, from the internet, etc. Write all your work yourself. It will be tempting to snarf a queue implementation from somewhere, but resist the temptation. Your code may be analyzed by plagiarism detection software. Any suspected copying must be reported to the CS Department Head, and the Academic Integrity Office for investigation. The minimum penalty for Academic Misconduct in CS is zero on the work, PLUS A SUBSTANTIAL ADDITIONAL PENALTY (such as a reduction in the course grade up to F). CourseNana.COM

Documentation:

Provide meaningful comments throughout (including functions etc). At the top of each source file, include a comment with your Name, Student ID, TMU email (note: that's TMU email, NOT your CS email.) CourseNana.COM

Marking:

This is the basic breakdown (subject to change). Further breakdown is not provided, as specifics depend on the given submission.

8 Director 8 Worker 16 Scheduler and Queue 3 Error-checking, robustness, etc. 3 Style and Documentation (modularity, algorithms, efficiency, etc.) CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Canada代写,Toronto Metropolitan University代写,CPS 590代写,CPS590代写,Operating Systems I代写,Scheduling Algorithms代写,C代写,Canada代编,Toronto Metropolitan University代编,CPS 590代编,CPS590代编,Operating Systems I代编,Scheduling Algorithms代编,C代编,Canada代考,Toronto Metropolitan University代考,CPS 590代考,CPS590代考,Operating Systems I代考,Scheduling Algorithms代考,C代考,Canadahelp,Toronto Metropolitan Universityhelp,CPS 590help,CPS590help,Operating Systems Ihelp,Scheduling Algorithmshelp,Chelp,Canada作业代写,Toronto Metropolitan University作业代写,CPS 590作业代写,CPS590作业代写,Operating Systems I作业代写,Scheduling Algorithms作业代写,C作业代写,Canada编程代写,Toronto Metropolitan University编程代写,CPS 590编程代写,CPS590编程代写,Operating Systems I编程代写,Scheduling Algorithms编程代写,C编程代写,Canadaprogramming help,Toronto Metropolitan Universityprogramming help,CPS 590programming help,CPS590programming help,Operating Systems Iprogramming help,Scheduling Algorithmsprogramming help,Cprogramming help,Canadaassignment help,Toronto Metropolitan Universityassignment help,CPS 590assignment help,CPS590assignment help,Operating Systems Iassignment help,Scheduling Algorithmsassignment help,Cassignment help,Canadasolution,Toronto Metropolitan Universitysolution,CPS 590solution,CPS590solution,Operating Systems Isolution,Scheduling Algorithmssolution,Csolution,