I was reading this topic on process scheduling from this wonderful book “Understanding Operating Systems” by Ann McIver McHoes and Ida M. Flynn [1] which triggered a thought. For the uninitiated, Windows, Linux and the likes are called Operating Systems and they run on a hardware which might be called a computer. This post isn’t about Computer Jargon, but to understand one problem and hint at a possible solution to it, we need a context, right? So try to stay along and I’ll try to make the learning curve short and sweet.

To begin with, computers are our servants whom we tell what things we might like them to do for us. For example, download the digital copy of that movie from the internet and play a nice playlist from the hard disk while I read this cryptic blog post and try to figure out what is being implied. Please note that the computer cannot, as of yet, do the last part. Just like our brains, the computer can only process one task (process) in its brain (which is called the processor) at a time. This means that it can either tell you to shut up as you pile it with work, or it can do what you would do; Divide the time into slices, tag the jobs at hand with priorities, write them on lists or queues, put them on a fridge and then ask “Who’s next?” There you see, by prioritizing the work, we’ve tried to make the computer a productive and obedient servant. But in doing so, we have created a society of jobs that is clearly stratified. Next is the question, but before that…

Forget about computers and think about human societies. Okay, good! We all say that the modern reservation system (but I argue it is not modern enough) is clearly flawed. Our society is stratified. Let’s for a moment only focus on the stratification in terms of financial resourcefulness and social stature. We can easily fit people in clear queues just like we put our tasks in priority lists. Having done that, the question is “Who’s next?” The efficacy of the answer hangs delicately on the policy we shall choose. But there are pretty interesting questions we ought to ask ourselves, just like the scientists asked when evolving computers. Here’s an excerpt:

Multiple-level queues raise some interesting questions:

• Is the processor allocated to the jobs in the first queue until it is empty before moving to the next queue, or does it travel from queue to queue until the last job on the last queue has been served and then go back to serve the first job on the first queue, or something in between?

• Is this fair to those who have earned, or paid for, a higher priority?

• Is it fair to those in a low-priority queue?

• If the processor is allocated to the jobs on the first queue and it never empties out, when will the jobs in the last queues be served?

• Can the jobs in the last queues get “time off for good behaviour” and eventually move to better queues?”[1]

Alas, fairness is a relative term in such narrow context and I’ll always feel violated even if I suffer a one second delay. These questions, though asked from an OS designer’s point of view are as much relevant outside these silicon societies in our own societies of brick and mortar, and …people. Let’s dissect two of these possibilities in terms of fairness and unfairness which shall be representative of our social outlook.

  1. Complete the first queue and then move to second: What if the people in the first queue just keep on adding work in its tail? When does it end? It would starve many people of attention they need while services are being showered the people with high priority. It’s easy to be swayed by the alluring possibilities of appeasing the creamy layer. It seems fair from the perspective of the people who paid for the privilege, who could afford it, but what about the others? The mango man? What about those who are, let’s say, dried mangoes?
  2. Hop from queue to queue after completing a task on one: It is like if you are second, you are worse than the first of the next lower class and even worse than the first of the lowest class. Cut throat competition. Ah, that could actually help. They’d probably fight among themselves and numerous would be lost to mere attrition that the competition brings. But again, is that fair? For any particular strata in general? Everyone is for himself even though we’ve marked them well on the basis of what they possess.

It makes these classes look grotesque and wrong, it makes us hate them for being there, notwithstanding the reasons they were made in the first place. But can we risk going back to the Stone Age and start over again or rather stand here and refine ourselves like people of science?

The entire race of the human race from wanderers through fiefdoms to kingdoms and to what we are today spans centuries; and look! The silicon societies managed to go through it and possibly over it at a nascent age of barely 50 or 60 years? It is one of the outcomes of this cutthroat competition to be more privileged that the others. But it would be foolish to think that we cannot learn from machines. Machines have benefitted from human knowledge that was not limited by its scope to computer science or electronics. For example, the allocation of memory to requesting processes has to be done in such a way that the computer does not run out of it while also meeting the criteria that processes are seldom denied these crucial resources. And guess what, the solution is the banker’s algorithm. How can a bank give loans to people without running out of money itself? Bank leases money, and computer leases resources and knows how to drive the nail in the coffin if you refuse to pay your dues. This is just one example. So if you may be convinced that we can indeed learn from the geeks who made it possible, I shall present, what the author calls the fairest of all methods.

As I said, first we have to constrain ourselves with the type of stratification which shall help us determine policy. The policy as such is pretty much generic enough to be applied on any stratification provided we don’t mix them, something we are quite adept at. The method is to shift the queues of the jobs as they are serviced for a time slice. The priorities are not fixed. So, if you are on the top of the highest queue, as soon as your time slice expires and you are not quite done with the job, you are directed to the end of the next lower queue. The concept of priority holds as long as you are in the queue for the very first time, as soon as your request enters the system, it is treated as any other request and is moved to the end of the next lower queue. This is the downward movement of a higher priority job. Similarly, a lower priority job does indeed get promoted to the end of the first queue as soon as it is ready with everything else that it needs (in the case of computers, it might be some Input/Output resource which might even be a click from the user, ‘yes, close that tab for God sake’). So if everything goes well, every job that was once least priority will at some time become top priority and even if it does not become the leader of the highest pack, it does get its slice of undivided attention from the processor. So, if I am using my links to get a backdoor entry (high priority queue) to the registration office once and I forget to bring some documents that are needed, I will be sent back to fetch them and next time, stand in line. While, other people, who came from the front door and were put in the (next priority) queue now get their registrations done.

Well, it is not completely fair to be honest, but no one claimed it to be so either. If I am paying the price, then I get to squeeze the juice too. But that is unfair to the one who cannot pay in the first place. He should be content if his chance is not killed by my intervention, if only delay a little. It is the fairest of them all. The thing is, we fragment the society to ease the social mechanism. On a personal scale, don’t we categorize people in terms of near and dears, distant relatives, chuddy-buddies, best friends forever, good friends, just friends, friends with benefits, acquaintances, the whiner, the dependable, the irresponsible, the humorous ones, the glum ones, the stupid ones, the attractive ones? Doesn’t our behavior change with each person? Are we being fair? No!

If equality is to be made a propaganda, then I like the misanthropes who hate all in general. But we have to draw lines, because that is how we are made. Because love is a miserly thing which makes itself look like the most pious thing in the world and sometime or the other, we need it badly.

…What mad Nijinsky wrote

About Diaghilev

Is true of the normal heart;

For the error bred in the bone

Of each woman and each man

Craves what it cannot have,

Not universal love

But to be loved alone…

~Auden

What we need is not a completely fair society and one might conclude that we need subtle benchmarks to rate or berate how we fare. I could say we need a just society but what is justice to me might be inhuman to you. It will be very dangerous to bring all the people to the same status unless each one arrives at his/her station. But arriving at a station and never leaving brings us to the point where it all started, yet again. There are no absolutes. It would be a human error to remove all disparities and wrong still if we do nothing about them. This debate is not new, and definitely not only for the third world countries. Once, Casanova and Voltaire argued over this and whom you side with is your wisdom.

“He [Casanova] got into a published dispute with Voltaire over religion. When he asked, "Suppose that you succeed in destroying superstition. With what will you replace it?" Voltaire shot back, "I like that. When I deliver humanity from a ferocious beast which devours it, can I be asked what I shall put in its place?" From Casanova’s point of view, if Voltaire had "been a proper philosopher, he would have kept silent on that subject ... the people need to live in ignorance for the general peace of the nation". [2]

Touché!

P.S. I sided with Casanova. :)

[1] Ann McIver McHoes and Ida M. Flynn, “Understanding Operating Systems”, Page 127, ISBN-13: 978-1-4390-7920-1, ISBN-10: 1-4390-7920-x.

[2] http://en.wikipedia.org/wiki/Giacomo_Casanova#cite_note-69