Northwest Missouri State University Advanced Operating System Summary Report Read the chapters for this week and use this Assign2 to submit your written su

Northwest Missouri State University Advanced Operating System Summary Report Read the chapters for this week and use this Assign2 to submit your written summary report of the understanding of the chapters. After, use safe Assign to check the originality of your paper. The report of safe assign should be lower than 5percent and you have three chances to submit your work. Use AMA citation. Thank you The Multi-Level Feedback Queue
and The Lottery Scheduling
Advanced OS
Chapter 8 and 9
Objectives
Basic Rules
How To Change Priority
A Single Long-Running Job
Priority Boost
Basic Concept: Tickets Represent Your Share
Ticket Mechanisms
Implementation
How To Assign Tickets
Stride Scheduling -Determinstic
Introduction
• One of the most well-known approaches to scheduling, is known as the Multi-level
Feedback Queue (MLFQ).
• The Multi-level Feedback Queue (MLFQ) scheduler tries to address two-fold
problems.
• First, it would like to optimize turnaround time, which, as we saw in the previous note, is
done by running shorter jobs first; unfortunately, the OS doesn’t generally know how long a
job will run for, exactly the knowledge that algorithms like SJF (or STCF) require.
• Second, MLFQ makes a system feel responsive to interactive users (i.e., users sitting and
staring at the screen, waiting for a process to finish), and thus minimize response time;
unfortunately, algorithms like Round Robin reduce response time but are terrible for
turnaround time.
Challenge
• HOW TO SCHEDULE WITHOUT PERFECT KNOWLEDGE?
• How can we design a scheduler that both minimizes response time for
interactive jobs while also minimizing turnaround time without a priori
knowledge of job length?
MLFQ: Basic Rules
• Rule 1: If Priority(A) > Priority(B), A runs (B doesn’t).
• Rule 2: If Priority(A) = Priority(B), A & B run in RR.
[High Priority]
Q8
A
B
Q7
Q6
Q5
Q4
C
Q3
Q2
[Low Priority] Q1
D
The Multi-Level FeedBack Queue
Basic Rules
• Two jobs (A and B) are at the highest priority level, while job C is in the
middle and Job D is at the lowest priority.
• Given our current knowledge of how MLFQ works, the scheduler would just
alternate time slices between A and B because they are the highest priority
jobs in the system;
• Jobs C and D would never even get to run — disappointing
• Need to change priorities for others
Attempt #1: How To Change Priority
• • Rule 3: When a job enters the system, it is placed at the highest priority (the
topmost queue).
• • Rule 4a: If a job uses up an entire time slice while running, its priority is
reduced (i.e., it moves down one queue).
• • Rule 4b: If a job gives up the CPU before the time slice is up, it stays at the
same priority level.
Example 1: A Single Long-Running Job
• This is what happens when there has been a long running job in the system.
the job enters at the highest priority (Q2).
• After a single time-slice of 10 ms, the scheduler reduces the job’s priority by
one, and thus the job is on Q1.
• After running at Q1 for a time slice, the job is finally lowered to the lowest
priority in the system (Q0), where it remains.
Q2
Q1
——————————————-
Q0
0
——————————————100
150
200
50
Long-Running Job Overtime
Example 2: Along Came A Short Job
• Here there are two jobs: A, which is a long-running CPU-intensive job, and B,
which is a short-running interactive job.
• Assume A has been running for some time, and then B arrives. because it doesn’t
know whether a job will be a short job or a long-running job,
• it first assumes it might be a short job, thus giving the job high priority. If it actually
is a short job, it will run quickly and complete;
• if it is not a short job, it will slowly move down the queues, and thus soon prove
itself to be a long-running more batch-like process. In this manner, MLFQ
approximates SJF.
Q2
Q1
Q0
B
B
——————————————A
A
——————————————100
150
200
50
0
Long-Running and Short-Running Jobs
Problems With Our Current MLFQ
• First, there is the problem of starvation:
•
•
if there are “too many” interactive jobs in the system, they will combine to consume all CPU time,
Meaning long-running jobs will never receive any CPU time (they starve)
• Second, gaming the scheduler. refers to the idea of doing something sneaky to trick the scheduler to give you
more than your fair share of the resource.
• This algorithm is vulnerable to the following attack: before the time slice is over, an I/O operation can be
issued (to some ?le you don’t care about) and thus relinquish the CPU; doing so allows the program to
remain in the same queue to gain a higher percentage of CPU time. A resource running for 99% of a time
slice before relinquishing the CPU) will monopolize the CPU.
• Finally, a program may change its behavior over time; what was CPU bound may transition to a phase of
interactivity. With our current approach, such a job would be out of luck and not be treated like the other
interactive jobs in the system.
Attempt #2: The Priority Boost
• We need to change the rules and see if we can avoid the problem of starvation.
• What could we do in order to guarantee that CPU-bound jobs will make some progress (even if
it is not much?).
• The simple idea here is to periodically boost the priority of all the jobs in system. There are many ways to
achieve this, but let’s just do something simple: throw them all in the topmost queue; hence, a new rule:
• • Rule 5: After some time period S, move all the jobs in the system to the topmost queue.
• Our new rule solves two problems at once.
• First, processes are guaranteed not to starve: by sitting in the top queue, a job will share the CPU with other
high-priority jobs in a round-robin fashion, and thus eventually receive service.
• Second, if a CPU-bound job has become interactive, the scheduler treats it properly once it has received the
priority boost.
Attempt #3: Better Accounting
• To prevent gaming of our scheduler, we need to solve Rules 4a and 4b, which let a job retain
•
•
•
•
its priority by relinquishing the CPU before the time slice expires.
So what should we do?
The solution here is to perform better accounting of CPU time at each level of the MLFQ.
Instead of forgetting how much of a time slice a process used at a given level, the scheduler
should keep track; once a process has used its allotment, it is demoted to the next priority
queue. Whether it uses the time slice in one long burst or many small ones does not matter.
We rewrite Rules 4a and 4b to the following single rule:
Rule 4: Once a job uses up its time allotment at a given level (regardless of how many times
it has given up the CPU), its priority is reduced (i.e., it moves down one queue).
Attempt #3: Better Accounting – cont.
• Without any protection from gaming, a process can issue an I/O just before
a time slice ends and thus dominate CPU time. With the new rule which puts
protection in place, regardless of the I/O behavior of the process, it slowly
moves down the queues, and thus no process can gain an unfair share of the
CPU.
Rules in Brief
•
•
•
•
•
The re?ned set of MLFQ rules, used in the chapter, are:
Rule 1: If Priority(A) > Priority(B), A runs (B doesn’t).
Rule 2: If Priority(A) = Priority(B), A & B run in RR.
Rule 3: When a job enters the system, it is placed at the highest priority (the topmost queue).
Rule 4: Once a job uses up its time allotment at a given level (regardless of how many times
it has given up the CPU), its priority is reduced (i.e., it moves down one queue).
• Rule 5: After some time period S, move all the jobs in the system to the topmost queue.
Priori Knowledge
• MLFQ is used in some form for the following reasons in UNIX, Solaris and
Windows as their base scheduler.
• instead of demanding a priori knowledge of the nature of a job, it observes
the execution of a job and prioritizes it accordingly. In this way, it manages to
achieve the best results
• It can deliver excellent overall performance (similar to SJF/STCF) for shortrunning interactive jobs, and
• It is fair and makes progress for long-running CPU-intensive workloads.
Lottery Scheduling
Basic Concept: Tickets Represent Your Share
• Tickets are used to represent the share of a resource that a process (or user or whatever) should receive.
• The percent of tickets that a process has represents its share of the system resource in question.
•
•
•
•
Example. Imagine two processes, A and B
A has 75 tickets
while B has 25.
So A receives 75% of the CPU and B the remaining 25%.
• Lottery scheduling achieves this probabilistically (but not deterministically) by holding a lottery every so
often (say, every time slice).
• Holding a lottery is straightforward: the scheduler must know how many total tickets there are (in our
example, there are 100).
Basic Concept: Tickets Represent Your Share –
cont.
•
•
•
•
•
The scheduler then picks a winning ticket, which is a number from 0 to 99
Assuming A holds tickets 0 through 74 and
B 75 through 99
The winning ticket simply determines whether A or B runs.
The scheduler then loads the state of that winning process and runs it.
Here is an example output of a lottery scheduler’s winning tickets:
63 85 70 39 76 17 29 41 36 39 10 99 68 83 63 62 43 0 49 49
Here is the resulting schedule:
A B A A B A A A A A A B A B A A A A AA
Basic Concept: Tickets Represent Your Share –
cont.
• The example illustrates the use of randomness in lottery scheduling which
leads to a probabilistic approach to meet the desired proportion with no
guarantee.
• B run 4 out of 20 time slices (20%) instead of the desired 25% allocation.
• But the longer the two jobs compete, the more likely they are to achieve the
desired percentages.
Ticket Currency
• Lottery scheduling provides a number of mechanisms to manipulate tickets in different and sometimes useful ways.
• One way is with the concept of ticket currency.
• Currency allows a user with a set of tickets to allocate tickets among their own jobs in whatever currency they would like;
the system then automatically converts said currency into the correct global value.
•
•
•
•
•
•
For example, assume users A and B have each been given 100 tickets.
User A is running two jobs, A1 and A2, and gives them each 500 tickets (out of 1000 total) in User A’s own currency.
User B is running only 1 job and gives it 10 tickets (out of 10 total).
The system will convert A1’s and A2’s allocation from 500 each in A’s currency to 50 each in the global currency and
B1’s 10 tickets will be converted to 100 tickets.
The lottery will then be held over the global ticket currency (200 total) to determine which job runs.
User A -> 500 (A’s currency) to A1 -> 50 (global currency)
-> 500 (A’s currency) to A2 -> 50 (global currency)
User B -> 10 (B’s currency) to B1 -> 100 (global currency)
Ticket transfer
• Ticket transfer is a useful mechanism. With transfers, a process can temporarily
hand off its tickets to another process.
• This ability is especially useful in a client/server setting, where a client process sends
a message to a server asking it to do some work on the client’s behalf.
• To speed up the work, the client can pass the tickets to the server and thus try to
maximize the performance of the server while the server is handling the client’s
request.
• When finished, the server then transfers the tickets back to the client and all is as
before.
Ticket inflation
• Ticket inflation can sometimes be a useful technique.
• With inflation, a process can temporarily raise or lower the number of tickets it
owns.
• In a competitive scenario with processes that do not trust one another, one greedy
process could give itself a vast number of tickets and take over the machine.
• Inflation can be applied in an environment where a group of processes trust one
another; in such a case, if any one process knows it needs more CPU time, it can
boost its ticket value as a way to reflect that need to the system, all without
communicating with any other processes.
Implementation
•
•
•
•
•
Lottery scheduling has simple implementation.
All you need is a good random number generator to pick the winning ticket
A data structure to track the processes of the system (e.g., a list) and
The total number of tickets.
Let’s assume we keep the processes in a list. Here is an example comprised
of three processes, A, B, and C, each with some number of tickets.
Lottery Scheduling Decision Code
// counter: used to track if we’ve found the winner yet
int counter = 0;
// winner: use some call to a random number generator to
// get a value, between 0 and the total # of tickets
int winner = getrandom(0, totaltickets);
// current: use this to walk through the list of jobs
node_t *current = head;
// loop until the sum of ticket values is > the winner
while (current) {
counter = counter + current->tickets;
if (counter > winner)
break; // found the winner
current = current->next;
}
// ’current’ is the winner: schedule it…
Implementation – cont.
• To make a scheduling decision,
•
•
•
we first have to pick a random number (the winner) from the total number of tickets (400)2
Let’s say we pick the number 300.
Then, we simply traverse the list, with a simple counter used to help us find the winner (Figure 9.1).
• The code walks the list of processes, adding each ticket value to counter until the value exceeds winner.
• Once that is the case, the current list element is the winner.
• With our example of the winning ticket being 300, the following takes place. First, counter is incremented to
100 to account for A’s tickets; because 100 is less than 300, the loop continues.
• Then counter would be updated to 150 (B’s tickets), still less than 300 and thus again we continue.
• Finally, counter is updated to 400 (clearly greater than 300), and thus we break out of the loop with current
pointing at C (the winner).
Head
Job: A
Tix: 100
Job: B
Tix: 50
Job: C
Tix: 250
Null
How To Assign Tickets?
• One problem we have not addressed with lottery scheduling is: how to assign tickets
•
•
•
•
to jobs?
This problem is a tough one, because of course how the system behaves is strongly
dependent on how tickets are allocated.
One approach is to assume that the users know best; in such a case, each user is
handed some number of tickets, and a user can allocate tickets to any jobs they run
as desired.
However, this solution is a non solution: it really doesn’t tell you what to do.
Thus, given a set of jobs, the “ticket-assignment problem” remains open.

Purchase answer to see full
attachment

Don't use plagiarized sources. Get Your Custom Essay on
Northwest Missouri State University Advanced Operating System Summary Report Read the chapters for this week and use this Assign2 to submit your written su
Just from $13/Page
Order Essay
Homework On Time
Calculate the Price of your PAPER Now
Pages (550 words)
Approximate price: -

Why Choose Us

Top quality papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional academic writers

We have hired a team of professional writers experienced in academic and business writing. Most of them are native speakers and PhD holders able to take care of any assignment you need help with.

Free revisions

If you feel that we missed something, send the order for a free revision. You will have 10 days to send the order for revision after you receive the final paper. You can either do it on your own after signing in to your personal account or by contacting our support.

On-time delivery

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & confidential

We use several checkers to make sure that all papers you receive are plagiarism-free. Our editors carefully go through all in-text citations. We also promise full confidentiality in all our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

Essay Writing Service

You are welcome to choose your academic level and the type of your paper. Our academic experts will gladly help you with essays, case studies, research papers and other assignments.

Admissions

Admission help & business writing

You can be positive that we will be here 24/7 to help you get accepted to the Master’s program at the TOP-universities or help you get a well-paid position.

Reviews

Editing your paper

Our academic writers and editors will help you submit a well-structured and organized paper just on time. We will ensure that your final paper is of the highest quality and absolutely free of mistakes.

Reviews

Revising your paper

Our academic writers and editors will help you with unlimited number of revisions in case you need any customization of your academic papers