I'm studying Real Time Systems, and in the textbook most of the focus is on scheduling algorithms. (Textbook: Real-Time Systems by Jane W. S. Liu)
In the algorithms that involve priorities, it is said that smaller integer represents higher priority (e.g. a process with priority 1 has more priority than one with 3). Then, in the subsequent discussions, there are terms involved like: "Let Pi be a process with a higher priority..." On such occurrences, I get confused whether higher priority means actually higher priority or larger integer. In most of the cases it means the former, however sometimes I've to guess that from the context, which is a bit time consuming.
As far as I know, all algorithms will work well with slight modifications if larger integers represented higher priority, and that would avoid confusion. So my question is: Is there any reason, apart from conventional / historical one, for using smaller integer for denoting higher priority? If not, why not amend it and avoid confusion?
Asked By : taninamdar
Answered By : Wandering Logic
This has always troubled me too. The problem is with the origins of the English word and the difference between ordinal numbers ("first", "second", "third", ...) and cardinal numbers (the numbers you use to count things).
In schedulers we use the word priority in the sense of:
the right to take precedence or to proceed before others[1]
It came into English from Norman French after the Norman conquest of England in 1066. It came into Norman French from the Latin word prior, which (in English) means
existing or coming before in time, order, or importance[1]
I added the emphasis on the word order to emphasize that we are using the word in the sense that requires we use ordinal numbers. So you should think of it in terms of a medieval court hierarchy. The king is seated at the dinner table first because he has the highest rank. The prince (etymology: via Norman French from Latin princeps, which means "first citizen"[2]) is seated second because he has the next highest rank. Then the dukes are seated third because they have the next highest rank. And so on. The knights are seated last because they have the lowest rank. (The common folk with no title don't get seated at all because they have no rank at all.)
[1] This is from the definition from Google. I think they may have gotten it from Oxford English Dictionary. [2]http://en.wikipedia.org/wiki/Royal_and_noble_ranks
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/32781
0 comments:
Post a Comment
Let us know your responses and feedback