450 likes | 690 Views
Multimedia III Multimedia Systems Issues. CS 423, Fall 2007 Klara Nahrstedt/Sam King. Multimedia OS vs. Conventional OS. Real time constraints! Process scheduling Rate Monotonic Scheduling Earliest Deadline First File System Data must be supplied immediately VCR operations
E N D
Multimedia IIIMultimedia Systems Issues CS 423, Fall 2007 Klara Nahrstedt/Sam King
Multimedia OS vs. Conventional OS • Real time constraints! • Process scheduling • Rate Monotonic Scheduling • Earliest Deadline First • File System • Data must be supplied immediately • VCR operations • Multiple Users • File Placement • Caching • Disk Scheduling • Predictable • Static vs. Dynamic
Scheduling Environments • Traditional scheduling (time-sharing computers) • optimal throughput • optimal resource utilization • fairness • Traditional real time scheduling • guaranteed hard deadlines with no adaptation to changes of the workload • operations completed after deadline are useless • Multimedia scheduling • guaranteed soft deadlines, i.e., work in a dynamic environment with adaptation to changes of the workload in bounds of timing requirements • operations completed after deadline result in decreased quality
Multimedia Process Scheduling • Simplest case: files are fixed size, fixed resolution, fixed number of them. • Round robin is sufficient • Realistic case: • variable size • variable resolution (thus variable cpu time) • variable number
Real Time Processing • Tasks • Schedulable unit of the system • Timing Constraints • Periodic • Deadlines • Resource Requirements • CPU Time • Assumed independent • Preemptive or Non-preemptive • Task Manger • Admission Control • Determines a schedule • Must provide guarantees
S Ci Pi m < 1 U = i Schedulability • Scheduling algorithm guarantees a newly arrived task a deadline if the algorithm can find a feasible schedule. • Process utilization: • m: number of process • Ci: CPU time for process i • Pi: period of process i
Rate-Monotonic Scheduling • Process Requirements: • Must complete within period • Independent • Constant amount of CPU time per burst • If non-periodic then must not have deadlines • Preemptions are instant • Process priority is determined by the task rate • Example: process runs every 40 ms => 1000/40 = 25Hz => priority of 25 • Higher frequency equals higher priority • Higher priority process can preempt lower priority process
Deadline-Based Scheduling • Process priority is determined by the process deadline. • Earliest Deadline First
Real Time Scheduling • Schedulability: • U = 10/30 + 15/40 + 5/50 = 0.808 • ~ 80% of the CPU is utilized • Schedulable!
Real Time Scheduling • Schedulability: • U = 15/30 + 15/40 + 5/50 = 0.975 • ~ 98% of the CPU is utilized • Schedulable!
S S Ci Pi Ci Pi m m < m(21/m-1) < 1 U = U = i i Admission Control • RMS • Liu and Layland proved in 1973 that a schedule could be guaranteed if: • m=3, U<0.780 • EDF • 100% utilization can be achieved :
Exam Problem • Consider three pre-emptible tasks: • Task A with PA = 200 ms, and CA = 60 ms • Task B with PB = 100 ms, CB = 40ms • Task C with PC = 1000 ms, CC = 10ms • Are these tasks schedulable at all? If yes, why, with which scheduling algorithm, and what is the schedule of tasks? If not, why not?
Exam Problem • Schedulability: • U = 60/200 + 40/100 + 10/1000 = 0.710 • < 0.780 so schedulable for RMS • Deadlines not provided so not schedulable for EDF
Multimedia File Systems • High data transfer rates • Large storage requirments • Data must be provided without delay • multimedia file server (video on demand) • difficult when requests are unplanned • Replace read system call with start • server then sends data at required rate • leave it to the user to handle the frame rate • user issues stop when finished • user can issue pause • rewind is easy, server simply starts over
Fast Forward and Rewind • Play back media at a higher rate than recorded (this is impractical) • Uncompressed data: • simply show every kth frame • Compressed data: • if frames are independent just need index of frames to find every kth • MPEG: I, P, and B frames • server uncompresses and recompresses every kth as I-frame • increase the amount of data transferred over the network • Plan ahead: create MPEG file with every 10th frame • audio and video are ussually separate!
Multiple Users • k users viewing the same movee = k users viewing k different movies • Near Video on Demand: • force user to watch at certain times • every 5 mins => 24 streams for 2 hour movie • No VCR functions • bus vs. taxi analogy
Adding VCR functions • Client buffers previous DT minutes and upcoming DT minutes • entails reading 2 streams at once • Data rate of 4Mbps, 10 minute buffer = 300 MB • If user fast forwards past buffer server can activate a temporary private stream • when user stops, refill buffer from next nearest stream • when caught up: • play from buffer • drop private stream • continue refilling buffer as before
File Placement • Multimedia files: • large • written once • read many times • read sequentially • strict quality of service criteria! • avoid seeking in middle of a frame • Single disk: • contiguous • small block model • large block model
Contiguous File Placement • Simple and avoids seeks within frames • Reasonable if planned ahead and layout doesn’t change • Problem if video, audio, and text in separate files • Interleave data: • No seeks on a single user system • Wastes resources reading unwanted data • Random access, fast forward/backward are impossible
Small / Large Block Models • Non-contiguous storage • Small Disk Block – disk block smaller than average frame size • Use Frame Index (Frame consists of all audio, video/text tracks for that frame as a contiguous run of disk blocks) • Called Constant Time Length • Large Disk Block – put multiple frames in each block • Use Block Index • Possibly store start frame • Called Constant Data Length • What are the tradeoffs? Disk blocks are larger than frames Disk blocks are smaller than average frame size
Large Block Model • Pros: • Index contains fewer entries • 256KB blocks, 16 KB frame, ~16 frames per block => 216,000 frames needs 13,500 entries • Runs disk at full speed • Cons: • Full N frames likely won’t fit in block • Leave unused: internal fragmentation, wasted space • Break frame: force seek within some frames • Double buffering hard • Fast forwarding requires massive I/O • Can use separate 10x file
Small Block Model • Pros: • Little disk waste • Double buffering easy (current/next frames) • Fast forward by displaying I-frames only • Cons: • Larger index • Page • Must store hole sizes (can’t use free list/bitmap) • Store lists for vaious size holes (per cylinder group)
Multiple Files on a Single Disk • Near Video on Demand • 5 min interval, 2 hour movie = 24 streams • store the 24 frames together • Some movies are more popular than others, hence we should take popularity into account • Zipf’s Law • Probability that the next customer will choose the item ranked ‘k-th’ in the popularity list is C/k, where C is normalization constant • C/1 + C/2 + …. + C/N = 1 9/22/2014 26
Organ-Pipe Algorithm • Place more popular files near center of disk • N=1000, P(top 5) = 0.307 • Head will be over these cylinders ~30% of the time
Caching • Multimedia Files ussually read from beginning to end • LRU doesn’t fit • Block Caching • File Caching
Block Caching • Multiple readers start to watch movie close to each other. • Store read block until all users have viewed it • Time between viewers determines size of cache needed • Merge streams • spead one up while slowing another down • use commercials
File Caching • In case files are very large (most movies are over 2GB), video servers cannot store movies on the disks • Servers keep the movies on DVDs or tapes • Cache/bring to the disk movie only if requested – means long start-up latency • Cache few first minutes of each movie on disk
Multimedia Disk Scheduling • Unlike regular files, these are very predictable • Static • Dynamic
Static Disk Scheduling Assumes all movies have the same frame rate Break stream frame requests into rounds sort blocks seek in order double buffer rounds for efficiency 9/22/2014 32
Dynamic Disk Scheduling • Movies have different frame rates • Requests appear more or less random • Requests have deadline (to maintain frame rate) • subract off service time • Scan-EDF • EDF: Serve requests whose deadlines are first • SCAN: Serve requests along the head movement • Collect requests whose deadlines are relatively close together and process these in cylinder order.
Conclusions • Multimedia systems put enormous real-time and data rate demands on all parts of operating system • However, multimedia systems have one property that makes it easier to handle them and that is predictability in many cases which can be utilized
Outline • Multimedia Process Scheduling • Soft-Real-Time • Rate Monotonic Scheduling • Deadline-based Scheduling • Multimedia Storage • Placement • Caching • Disk Scheduling
Real-Time Processing Requirements • Occurs in predetermined - usually periodic – intervals • Complete at certain deadlines. • Real time process manager • performs admission control • determines a schedule • gives processing guarantees. • Goal of Multimedia Process Scheduling • non-RT process should not starve when RT process is running • RT process should not be subject to priority inversion. • Problem: how to find a feasible schedule.
System Model in RT Scheduling • Task is the schedulable unit of the system. • Task is characterized by (1) timing constraints and resource requirements.
Assumptions and Notation • Assumptions : periodic tasks are mutually independent. • Time Constraints : (s, e, d, p) where s is starting point, e is processing time, d is deadline, and p is period. • If the period at (k-1) step is equal to ready(start) time of period k, then we get congestion avoidance deadline. • Tasks : can be preemptive or non-preemptive. • Multimedia Scheduling Algorithm : must determine sharing of the resource used by different tasks so that all of them can meet their deadlines.
Schedulability • Scheduling algorithm guarantees a newly arrived task a deadline if the algorithm can find a feasible schedule. • Guarantee ratio := number of guaranteed tasks/total number of tasks • Another performance metric is process utilization with .
Admission Control Process utilization for RM algorithm is upper bounded by (Liu and Layland condition). The schedulability test is then With EDF algorithm, the 100% utilization can be achieved : The schedulability test is then 9/22/2014 40
RMS vs EDF • In terms of context switching, the EDF is better if more than one stream are processed concurrently
Multimedia Server • Multimedia file servers act like VCRs • Video-on-Demand systems • Near Video-on-Demand systems • Multimedia file servers with streaming model are often called push servers • Traditional file servers are called pull servers
Storage Requirements • Real-time Storage and Retrieval • High Data Transfer Rate and Large Storage Space • HDTV quality requires (1280x720 pixels/frame with 24 bits/pixel) 81 Mbytes per second • NTSC quality requires (640x480 pixels/frame with 24 bits/pixel) 27MBytes per second
Continuous Media Recording and Playback Media Quanta Quanta read from server disk Quanta Buffered Quanta consumed Time Challenge of multimedia server is to ensure continuous retrieval of a media Stream from the disk.
Support of Continuous Media • Our goal is to provide a constant and timely retrieval of data. • Following approaches are taken • Proper management of multimedia disk storage; result is an optimized organization of files on disk • Admission control for different service classes • Special disk scheduling algorithms and sufficient buffers to avoid jitter