Desktop Scheduling. Scheduling Metric. Real-Time Priority. What can be done automatically?

Operating systems’ schedulers need a new metric to identify and prioritize interactive and multimedia jobs. 100 Xine X server Stressors other 80 60 ...
Author: Emory Hart
7 downloads 3 Views 127KB Size
Operating systems’ schedulers need a new metric to identify and prioritize interactive and multimedia jobs. 100

Xine X server Stressors other

80 60 40 20

IDLE

You are running some long simulations. In the mean time, why not watch an illegally downloaded Simpsons episode? How can the operating system know that the movie player slowdown is much more perceivable than the batch process slowdown?

Scheduling Metric

CPU utilization [%]

Desktop Scheduling

frame loss [%]

0 0

1

2

3

4

5

6

7

8

9 10

Number of Stressors 4.1 Advanced Operating Systems– Wiseman 2004

Real-Time Priority Most of UNIX and Windows versions support a real-time scheduling. A real-time process is served before the other processes will be served. In some OSes the real-time definition is set on coding time, while in some other OSes the definition can be set on running time. Both shift the burden to the user/programmer 4.3 Advanced Operating Systems– Wiseman 2004

4.2 Advanced Operating Systems– Wiseman 2004

What can be done automatically? Desktop operating systems prioritize processes based on CPU consumption. – The less CPU consumed by a process, the higher its priority.

It’s good for fairness: – Each process gets a fair share of the CPU. – Processes that wake up get a higher priority.

This scheme originates from UNIX (1970s). And… operating systems still work that way. 4.4 Advanced Operating Systems– Wiseman 2004

Linux Non-Realtime Scheduling The Linux scheduler partitions time into epochs. In each epoch, every process has an allocation of how long it may run. When there are no ready processes with an allocation left, a new epoch is started. The calculation of the allocation is based on: – The "nice" value. – Processes that did not use up all their previous allocation transfer half of it to the new epoch.

Windows 2000 Scheduling The "nice" value of Windows 2000 is called "thread's type". There are also some dynamic rules: – Threads associated with the focus window get a triple quantum. • Multi-Media threads are not always in the focus window.

– After an I/O wait, the priority is boosted by a factor that is inversely proportional to the speed of the I/O device. This is then decremented by one at the end of each quantum, until the original priority is reached again. • Keyboard and mouse are very slow; hence contribute a big boost.

4.5 Advanced Operating Systems– Wiseman 2004

What About Interactivity? In its early days, interactive computing was text based. – Drawing text does not require much CPU. – User input devices are very slow.

Interactive jobs waited a lot, and consumed little CPU. Result: the little-CPU-long-waits-highpriority scheme favored interactive jobs. Unfortunately, this is no longer the case. 4.7 Advanced Operating Systems– Wiseman 2004

4.6 Advanced Operating Systems– Wiseman 2004

Contemporary Interactive Applications Nowadays, applications use a lot of visual and audible means for user interaction e.g.: – Window based systems and the graphical user interface widgets. – Movie players with CPU intensive decompression. – Games based on CPU massive graphical engines.

Modern Interactive and multimedia applications consume substantial amounts of CPU cycles. Let us denote such processes as HumanCentered, or HuC for short. 4.8 Advanced Operating Systems– Wiseman 2004

Voluntary Context Switches

CPU consumption can no longer separate the HuC processes from the rest – Mplayer and Xine are movie players and Quake is a computer game. 99.8 99.4 97.0

CPU Usage Percent

100

94.7

– Reactive nature. – Block on device. – Wait for a timer.

80 60 41.2

40 20

11.0 11.6

Cumulative Probability

0 0

10

20

30

40

50

0

10

20

30

40

50

Demo Quake Demo Stressor User Quake User Stressor

Demo Quake Stressor 0

10

20

30

40

50

0

40

14.3

20

1.2

0

0.5

Forced Voluntary

e

0.6

Kernel Make X (with Xine) MPlayer Xine

60

or ss ake re St l m e rn Ke o m de r ke ye ua la Q ep k ua Q ne Xi er ay e Pl fic M Of n pe O cs a

ak

m

or

ss

el

o

er

m

ay

de

pl

1 0.8

Emacs OpenOffice

81.6

Huc Characteristic

Effective Quantum Length is the interval from when a process is allocated a CPU, until the CPU is relinquished. Does a HuC process consume CPU time in small portions?

0.2

83.1 80

4.10 Advanced Operating Systems– Wiseman 2004

Effective Quantum Length

0.4

99.6 99.1 98.5

100

Em

re

ke

rn

ua

1

1

2:

1:

ke

ua

ne

ne

ce

ffi

er

ay

Pl

s

nO

ac

pe

Other X Server Application 4.9 Advanced Operating Systems– Wiseman 2004

St

Ke

Q

Q

Xi

O

Xi

2.6 M

0.2 Em

0

Switches that are induced by the process itself. Does a HuC process relinquish the CPU voluntarily more often? Context Switche Reason [%]

CPU Consumption

10

Effective Quantum Duration [milliseconds] 4.11 Advanced Operating Systems– Wiseman 2004

20

30

40

50

Because CPU consumption patterns cannot automatically identify HuC processes, the correct way is to directly quantify the amount of user interaction for the various processes. Devices that mediate between the user and a process will be called HuC devices e.g. keyboard, mouse, screen, joystick, speaker. – For now, we will focus on the first three… 4.12 Advanced Operating Systems– Wiseman 2004

– X saves user I/O statistics for each window. – These statistics are periodically reported to the operating system kernel.

Quantifying I/O with the user raises cognitive questions about relative importance of events. – Is a keyboard press more important than a mouse drag? – Is drawing a character more important than drawing an image? 4.13 Advanced Operating Systems– Wiseman 2004

Scheduling by I/O Quantification Windows with input are the most important ones. The next priority is widows with output. Windows without I/O are less important. Applications like Emacs are unaffected. – Emacs requires less than 1% of the CPU cycles and gets that in the old and the modified scheduler.

The responsiveness of the windows manager is also improved. – On heavy loaded systems the windows manager (using the old scheduler) finds difficult in moving windows around. 4.15 Advanced Operating Systems– Wiseman 2004

Input: – simply accumulate input events. – Dragging the mouse will generate multiple events, while clicking the mouse or a keyboard press are just one event. • The user is very slow!

Output: – quantify the changes produced by each graphical request. • In graphical shapes, count the pixels that have been changed. • In text, assume all of the pixels in the character's box have been changed.

– Do not count changes in hidden portions of the window. 4.14 Advanced Operating Systems– Wiseman 2004

Experimental Results Desktop Scheduling autonomously identifies HuC processes, and prioritizes them. 100

Xine X server Stressors other

80 60 40 20

IDLE

In UNIX, all user I/O is mediated by the X-Windows system - specifically by the X-Server. The X-Server has been modified a little:

The Simplest Solution

CPU utilization [%]

Quantifying User Interactions

frame loss [%]

0 0

1

2

3

4

5

6

7

8

9 10

Number of Stressors 4.16 Advanced Operating Systems– Wiseman 2004

HuC processes are usually time sensitive, so identifying them can improve their timing. Desktop Scheduling reduces the dispatch latency HuC processes incur.

Avg. dispatch latency [ms]

Dispatch Latency

Open Questions 14 12 10 8 6 4 2 0

OpenOffice Xine X (with Xine) Emacs

Before

0

1

2

3

4

5

6

7

8

9 10

2

3

4

5

6

7

8

9 10

After 6

Where does sound fit in? Is it practical to measure network bandwidth in order to improve streaming? How can other devices integrated into this model?

4 2 0 0

1

Number of Stressors

4.17 Advanced Operating Systems– Wiseman 2004

4.18 Advanced Operating Systems– Wiseman 2004