View
218
Download
0
Embed Size (px)
Citation preview
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 1
Multimedia Topics(continued)
CS-3013 & CS-502Operating Systems
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 2
Review
• CD-ROM & DVD devices• Reading assignment about CD-R and DVD
• General requirements for multimedia in a computer
• Jitter-free• Guaranteed scheduling• Multiple interleaved streams• Wide variety of bandwidths
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 3
Review (continued)
• Compression• MP-3 – 10:1• JPEG – 20:1• MPEG-2 – 50:1- 80:1
• Asymmetric compression• Longer to compress than to decompress• Take advantage of temporal locality
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 4
Outline
• Processor scheduling• File, disk, and network management
for multimedia in computers
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 5
Operating System Challenge
• How to get the contents of a movie file from disk or DVD drive to video screen and speakers.– Fixed frame rate (24, 25 or 30 fps)– Steady audio rate– Bounded jitter
• Classical problem in real-time scheduling– Obscure niche becomes mainstream!– See Silbershatz, Chapter 19
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 6
Two common methods
• Rate Monotonic Scheduling• Earliest Deadline First
• Many variations• Many analytic methods for proving
QoS (Quality of Service)
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 7
Processor Scheduling for Real-Time
Rate Monotonic Scheduling (RMS)• Assume m periodic processes
– Process i requires ti msec of processing time every pi msec.
– Equal processing every interval — like clockwork!
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 8
Example• Periodic process i requires the CPU at specified
intervals (periods)• pi is the duration of the period• ti is the processing time• di is the deadline by when the process must be
serviced– Often same as end of period
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 9
Processor Scheduling for Real-Time
Rate Monotonic Scheduling (RMS)• Assume m periodic processes
– Process i requires ti msec of processing time every pi msec.
– Equal processing every interval — like clockwork!
• Assume
• Assign priority of process i to be– Statically assigned
• Let priority of non-real-time processes be 0
11
m
i i
i
p
t
ip
1
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 10
Rate Monotonic Scheduling (continued)
• Scheduler simply runs highest priority process that is ready– May pre-empt other real-time processes– Real-time processes become ready in
time for each frame or sound interval– Non-real-time processes run only when
no real-time process needs CPU
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 11
Example
• p1 = 50 msec; t1 = 20 msec
• p2 = 100 msec; t2 = 35 msec
• Priority(p1) > Priority(p2)
• Total compute load is 75 msec per every 100 msec.
• Both tasks complete within every period• 25 msec per 100 msec to spare
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 12
Example 2
• p1 = 50 msec; t1 = 25 msec
• p2 = 80 msec; t2 = 35 msec
• Priority(p1) > Priority(p2)
• Total compute load is ~ 94% of CPU.
• Cannot complete both tasks within some periods• Even though there is still CPU capacity to spare!
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 13
Rate Monotonic Theorems (without proof)
• Theorem 1: using these priorities, scheduler can guarantee the needed Quality of Service (QoS), provided that
– Asymtotically approaches ln 2 as m ln 2 = 0.6931…
• Theorem 2: If a set of processes can be scheduled by any method of static priorities, then it can be scheduled by Rate Monotonic method.
)12(1
1
mm
i i
i mp
t
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 14
Example 2 again
• Note that p1 pre-empts p2 in second interval,
even though p2 has the earlier deadline!
828.01229375.080
35
50
25 21
2
2
1
1
p
t
p
t
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 15
More on Rate Monotonic Scheduling
• Rate Monotonic assumes periodic processes
• MPEG-2 playback is not a periodic process!
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 16
Processor Scheduling for Real-Time
Earliest Deadline First (EDF)
• When each process i become ready, it announces deadline Di for its next task.
• Scheduler always assigns processor to process with earliest deadline.
• May pre-empt other real-time processes
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 17
Earliest Deadline First Scheduling (continued)
• No assumption of periodicity• No assumption of uniform processing times
• Theorem: If any scheduling policy can satisfy QoS requirement for a sequence of real time tasks, then EDF can also satisfy it.– Proof: If i scheduled before i+1, but Di+1 < Di ,
then i and i+1 can be interchanged without affecting QoS guarantee to either one.
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 18
Earliest Deadline First Scheduling (continued)
• EDF is more complex scheduling algorithm
• Priorities are dynamically calculated• Processes must know deadlines for tasks
• EDF can make higher use of processor than RMS
• Up to 100%
• There is a large body of knowledge and theorems about EDF analysis
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 19
Example 2 (again)
• Priorities are assigned according to deadlines:
– the earlier the deadline, the higher the priority;– the later the deadline, the lower the priority.
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 20
Questions?
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 21
Multimedia File & Disk Management
• Single movie or multimedia file on PC disk– Interleave audio, video, etc.
• So temporally equivalent blocks are near each other
– Attempt contiguous allocation• Avoid seeks within a frame
TextFrame
AudioFrame
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 22
File organization – Frame vs. Block
• Frame organization• Small disk blocks (4-16 Kbytes)• Frame index entries point to starting block for each
frame• Frames vary in size (MPEG)• Advantage: very little storage fragmentation• Disadvantage: large frame table in RAM
• Block organization• Large disk block (256 Kbytes)• Block index entries point to first I-frame of a sequence• Multiple frames per block• Advantage: much smaller block table in RAM• Disadvantage: large storage fragmentation on disk
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 23
Frame vs. Block organization
smaller larger
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 24
File Placement on Server
• Random• Striped• “Organ pipe” allocation
– Most popular video in center of disk– Next most popular on either side of it– Etc.– Least popular at edges of disk– Minimizes seek distance
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 25
Placing Multiple files on Single Disk
Zipf’s Law• Rank items by “popularity”• Zif’s Law says: Probability that next
customer will choose item k is approximately C/k– Where C is a normalization constant such that
11
N
kk
C
N = 10 C = 0.341N = 100 C = 0.193N = 1000 C = 0.134N = 10000 C = 0.102
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 26
Zipf’s Law applied to US cities
• Points represent populations 20 largest cities– sorted on rank order
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 27
Application of Zipf’s Law tomovie file placement
• Organ-pipe distribution of files on server– most popular movie in middle of disk– next most popular either on either side, etc.
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 28
Calculate …
• Probability that next movie is in the middle five cylinders
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 29
Questions?
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 30
Disk Scheduling (server)
• Scheduling disk activity is just as important as scheduling processor activity
• Advantage:– Predictability• Unlike disk activity of ordinary computing
• In server, there will be multiple disk requests in each frame interval
• One request per frame for each concurrent video stream
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 31
Disk Scheduling (continued)
• SCAN (Elevator) algorithm for each frame interval
• Sort by cylinder #• Complete in time for start of next frame interval
• Variation – SCAN–EDF:• Sort requests by deadline• Group similar deadlines together, apply SCAN to
group• Particularly useful for non-uniform block sizes
and frame intervals
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 32
Network Streaming
• Traditional HTTP• Stateless• Server responds to each request
independently
• Real-Time Streaming Protocol (RTSP)• Client initiates a “push” request for stream• Server provides media stream at frame rate
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 33
Push vs. Pull server
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 34
Bandwidth Negotiation
• Client (or application) provides feedback to server to adjust bandwidth
• E.g., – Windows Media Player– RealPlayer– Quicktime
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 35
Conclusion
• Multimedia computing is challenging• Possible with modern computers
• Compression is essential, especially for video
• Real-time computing techniques move into mainstream
• Processor and disk scheduling
• There is much more to this subject than fits into one class
CS-3013 & CS-502, Summer 2006
Multimedia topics (continued) 36
Break