Operating Systems Design (Subject Code: 310242) (Class: TE Computer Engineering)
Unit No: 6
Advance Tools and Technologies(and Problem Solving in OS) Pavan R Jaiswal
Contents • • • • • • • • •
Multiprocessor scheduling Real time scheduling Linux scheduling UNIX free BSD scheduling Windows vista scheduling Windows-8 ReFS Embedded System Handheld Operating systems: Handheld systems-Requirements, Technology Overview : PalmOS, Microsoft Windows CE, Microsoft Windows Mobile, Google Android, • Other Handheld Operating systems • Securing Handheld systems • Frame of Reference for Handheld Systems.
9/29/2015
Advance Tools and Technologies (and Problem Solving)
2
Loosely coupled or distributed multiprocessor, or cluster • consists of a collection of relatively autonomous systems, each processor having its own main memory and I/O channels
Functionally specialized processors • there is a master, general-purpose processor; specialized processors are controlled by the master processor and provide services to it
Tightly coupled multiprocessor • consists of a set of processors that share a common main memory and are under the integrated control of an operating system 9/29/2015
Advance Tools and Technologies (and Problem Solving)
3
Synchronization Granularity and Processes
9/29/2015
Advance Tools and Technologies (and Problem Solving)
4
•
No explicit synchronization among processes • each represents a separate, independent application or job
• Typical use is in a time-sharing system
each user is performing a particular application multiprocessor provides the same service as a multiprogrammed uniprocessor because more than one processor is available, average response time to the users will be less
9/29/2015
Advance Tools and Technologies (and Problem Solving)
5
• Synchronization among processes, but at a very gross level • Good for concurrent processes running on a multiprogrammed uniprocessor – can be supported on a multiprocessor with little or no change to user software
9/29/2015
Advance Tools and Technologies (and Problem Solving)
6
• Single application can be effectively implemented as a collection of threads within a single process • programmer must explicitly specify the potential parallelism of an application • there needs to be a high degree of coordination and interaction among the threads of an application, leading to a medium-grain level of synchronization
• Because the various threads of an application interact so frequently, scheduling decisions concerning one thread may affect the performance of the entire application 9/29/2015
Advance Tools and Technologies (and Problem Solving)
7
• Represents a much more complex use of parallelism than is found in the use of threads • Is a specialized and fragmented area with many different approaches
9/29/2015
Advance Tools and Technologies (and Problem Solving)
8
Scheduling on a multiprocessor involves three interrelated issues:
actual dispatching of a process
9/29/2015
use of multiprogramming on individual processors
• The approach taken will depend on the degree of granularity of applications and the number of processors available
assignment of processes to processors
Advance Tools and Technologies (and Problem Solving)
9
Assuming all processors are equal, it is simplest to treat processors as a pooled resource and assign processes to processors on demand
static or dynamic needs to be determined
If a process is permanently assigned to one processor from activation until its completion, then a dedicated short-term queue is maintained for each processor
advantage is that there may be less overhead in the scheduling function
9/29/2015
Advance Tools and Technologies (and Problem Solving)
allows group or gang scheduling
10
• A disadvantage of static assignment is that one processor can be idle, with an empty queue, while another processor has a backlog
• to prevent this situation, a common queue can be used • All processes goto one global queue • Scheduled as per avilability of processor • Over lifetime of process it may get executed on different processor • another option is dynamic load balancing :used in Linux scheduling
9/29/2015
Advance Tools and Technologies (and Problem Solving)
11
• Both dynamic and static methods require some way of assigning a process to a processor • Approaches: – Master/Slave – Peer
9/29/2015
Advance Tools and Technologies (and Problem Solving)
12
• • • •
Key kernel functions always run on a particular processor Master is responsible for scheduling Slave sends service request to the master Is simple and requires little enhancement to a uniprocessor multiprogramming operating system • Conflict resolution is simplified because one processor has control of all memory and I/O resources
Disadvantages: • failure of master brings down whole system • master can become a performance bottleneck 9/29/2015
Advance Tools and Technologies (and Problem Solving)
13
• Kernel can execute on any processor • Each processor does self-scheduling from the pool of available processes Complicates the operating system • operating system must ensure that two processors do not choose the same process and that the processes are not somehow lost from the queue
9/29/2015
Advance Tools and Technologies (and Problem Solving)
14
• •
•
Usually processes are not dedicated to processors A single queue is used for all processors – if some sort of priority scheme is used, there are multiple queues based on priority System is viewed as being a multi-server queuing architecture
9/29/2015
Advance Tools and Technologies (and Problem Solving)
15
• •
9/29/2015
With static assignment: should individual processors be multiprogrammed or should each be dedicated to a single process? Often it is best to have one process per processor; particularly in the case of multithreaded programs where it is advantageous to have all threads of a single process executing at the same time.
Advance Tools and Technologies (and Problem Solving)
16
•
The operating system, and in particular the scheduler, is perhaps the most important component
Examples:
•
• • 9/29/2015
• control of laboratory experiments • process control in industrial plants • robotics • air traffic control • telecommunications • military command and control systems
Correctness of the system depends not only on the logical result of the computation but also on the time at which the results are produced Tasks or processes attempt to control or react to events that take place in the outside world These events occur in “real time” and tasks must be able to keep up with them Advance Tools and Technologies (and Problem Solving)
18
Hard real-time task
Soft real-time task
• one that must meet its deadline • otherwise it will cause unacceptable damage or a fatal error to the system
• Has an associated deadline that is desirable but not mandatory • It still makes sense to schedule and complete the task even if it has passed its deadline
9/29/2015
Advance Tools and Technologies (and Problem Solving)
19
• Periodic tasks – requirement may be stated as: • •
once per period T exactly T units apart
• Aperiodic tasks – has a deadline by which it must finish or start – may have a constraint on both start and finish time
9/29/2015
Advance Tools and Technologies (and Problem Solving)
20
Real-time operating systems have requirements in five general areas: Determinism Responsiveness User control Reliability Fail-soft operation 9/29/2015
Advance Tools and Technologies (and Problem Solving)
21
• Concerned with how long an operating system delays before acknowledging an interrupt • Operations are performed at fixed, predetermined times or within predetermined time intervals • when multiple processes are competing for resources and processor time, no system will be fully deterministic The extent to which an operating system can deterministically satisfy requests depends on: 9/29/2015
the speed with which it can respond to interrupts
Advance Tools and Technologies (and Problem Solving)
whether the system has sufficient capacity to handle all requests within the required time
22
• How to achieve determinism? – Maximum delay between arrival of event and response to the event
9/29/2015
Advance Tools and Technologies (and Problem Solving)
23
• Concerned with how long, after acknowledgment, it takes an operating system to service the interrupt • Together with determinism make up the response time to external events • critical for real-time systems that must meet timing requirements imposed by individuals, devices, and data flows external to the system Responsiveness includes: • amount of time required to initially handle the interrupt and begin execution of the interrupt service routine (ISR) • amount of time required to perform the ISR • effect of interrupt nesting 9/29/2015
Advance Tools and Technologies (and Problem Solving)
24
Servicing an interrupt • • • •
Execution of ISR If process switch then delay included Time of execution of ISR depends on hardware In case another interrupt occurs
9/29/2015
Advance Tools and Technologies (and Problem Solving)
25
• Generally much broader in a real-time operating system than in ordinary operating systems • It is essential to allow the user fine-grained control over task priority • User should be able to distinguish between hard and soft tasks and to specify relative priorities within each class • May allow user to specify such characteristics as: paging or process swapping 9/29/2015
what processes must always be resident in main memory
what disk transfer algorithms are to be used
Advance Tools and Technologies (and Problem Solving)
what rights the processes in various priority bands have 26
• More important for real-time systems than non-real time systems (reboot) • Real-time systems respond to and control events in real time so loss or degradation of performance may have catastrophic consequences such as: • financial loss • major equipment damage • loss of life
9/29/2015
Advance Tools and Technologies (and Problem Solving)
27
• •
A characteristic that refers to the ability of a system to fail in such a way as to preserve as much capability and data as possible Important aspect is stability • a real-time system is stable if the system will meet the deadlines of its most critical, highest-priority tasks even if some less critical task deadlines are not always met
9/29/2015
Advance Tools and Technologies (and Problem Solving)
28
whether a system performs schedulability analysis Scheduling approaches depend on:
9/29/2015
if it does, whether it is done statically or dynamically
whether the result of the analysis itself produces a scheduler plan according to which tasks are dispatched at run time
Advance Tools and Technologies (and Problem Solving)
29
• In a preemptive scheduler that uses simple round-robin scheduling, a real-time task would be added to the ready queue to await its next time slice,
9/29/2015
Advance Tools and Technologies (and Problem Solving)
30
• In a nonpreemptive scheduler, we could use a priority scheduling mechanism • Giving real-time tasks higher priority. In this case, a realtime task that is ready would be scheduled as soon as the current process blocks or runs to completion • This could lead to a delay of several seconds if a slow, lowpriority task were executing at a critical time. • Again, this approach is not acceptable 9/29/2015
Advance Tools and Technologies (and Problem Solving)
31
• A more promising approach is to combine priorities with clock-based interrupts. Preemption points occur at regular intervals. When a preemption point occurs, the currently running task is preempted if a higherpriority task is waiting. • This would include the preemption of tasks that are part of the operating system kernel. Such a delay may be on the order of several milliseconds
9/29/2015
Advance Tools and Technologies (and Problem Solving)
32
Static table-driven approaches • performs a static analysis of feasible schedules of dispatching • result is a schedule that determines, at run time, when a task must begin execution
Static priority-driven preemptive approaches • a static analysis is performed but no schedule is drawn up • analysis is used to assign priorities to tasks so that a traditional priority-driven preemptive scheduler can be used
Dynamic planning-based approaches • feasibility is determined at run time rather than offline prior to the start of execution • one result of the analysis is a schedule or plan that is used to decide when to dispatch this task
Dynamic best effort approaches • no feasibility analysis is performed • system tries to meet all deadlines and aborts any started process whose deadline is missed 9/29/2015
Advance Tools and Technologies (and Problem Solving)
33
• Real-time operating systems are designed with the objective of starting real-time tasks as rapidly as possible and emphasize rapid interrupt handling and task dispatching • Real-time applications are generally not concerned with sheer speed but rather with completing (or starting) tasks at the most valuable times • Priorities provide a crude tool and do not capture the requirement of completion (or initiation) at the most valuable time
9/29/2015
Advance Tools and Technologies (and Problem Solving)
34
Ready time Starting deadline
• time task becomes ready for execution
Resource requirements
• resources required by the task while it is executing
• time task must begin Priority
• measures relative importance of the task
Completion • time task must be completed deadline Processing time 9/29/2015
• time required to execute the task to completion
Subtask scheduler
Advance Tools and Technologies (and Problem Solving)
• a task may be decomposed into a mandatory subtask and an optional subtask
35
Table 10.2 Execution Profile of Two Periodic Tasks
9/29/2015
Advance Tools and Technologies (and Problem Solving)
36
Figure 10.5 Scheduling of Periodic Real-Time Tasks With Completion Deadlines (Based on Table 10.2) 9/29/2015
Advance Tools and Technologies (and Problem Solving)
37
Rate Monotonic Scheduling • Used in hard real time system • Schedules task using static priority policy with pre-emption • Priority is based on execution time • Less time left highest priority • Task rate (in Hertz ) is inversely proportional to its period. • A task with 50ms period will occur at rate of 20Hz 9/29/2015
Advance Tools and Technologies (and Problem Solving)
39
Rate Monotonic Scheduling
Figure 10.7 9/29/2015
Advance Tools and Technologies (and Problem Solving)
41
Periodic Task Timing Diagram
Figure 10.8 9/29/2015
Advance Tools and Technologies (and Problem Solving)
42
• The three classes are: – SCHED_FIFO: First-in-first-out real-time threads – SCHED_RR: Round-robin real-time threads – SCHED_OTHER: Other, non-real-time threads • Within each class multiple priorities may be used
9/29/2015
Advance Tools and Technologies (and Problem Solving)
43
Linux Real-Time Scheduling
9/29/2015
Advance Tools and Technologies (and Problem Solving)
44
•
The Linux 2.4 scheduler for the SCHED_OTHER class did not scale well with increasing number of processors and processes
•
In case if same process is scheduled on two different processor at two different instances then problem with data
9/29/2015
•
Runqueue gets blocked by executing CPU , other processor need to wait
Advance Tools and Technologies (and Problem Solving)
45
• Linux 2.6 uses a new priority scheduler known as the O(1) scheduler • Time to select the appropriate process and assign it to a processor is constant regardless of the load on the system or number of processors
• Kernel maintains two scheduling data structures for each processor in the system
9/29/2015
Advance Tools and Technologies (and Problem Solving)
46
Linux Scheduling Data Structures
Figure 10.11 9/29/2015
Advance Tools and Technologies (and Problem Solving)
47
• struct prio_array { int nr_active; /* number of tasks in this array*/ unsigned long bitmap[BITMAP_SIZE]; /* priority bitmap */ struct list_head queue[MAX_PRIO]; /* priority queues */ • A separate queue is maintained for each priority level. • The total number of queues in the structure is MAX_PRIO , which has a default value of 140. • The structure also includes a bitmap array of sufficient size to provide one bit per priority level. Thus, with 140 priority levels and 32-bit words, BITMAP_SIZE has a value of 5. • This creates a bitmap of 160 bits, of which 20 bits are ignored. • The bitmap indicates which queues are not empty. • Finally, nr_active indicates the total number of tasks present on all queues. • Two structures are maintained: an active queues structure and an expired queues structure. 9/29/2015
Advance Tools and Technologies (and Problem Solving)
48
• • • • • • • • • • • • • • • •
Initially, both bitmaps are set to all zeroes and all queues are empty. As a process becomes ready, it is assigned to the appropriate priority queue in the active queues structure and is assigned the appropriate timeslice. If a task is preempted before it completes its timeslice, it is returned to an active queue. When a task completes its timeslice, it goes into the appropriate queue in the expired queues structure and is assigned a new timeslice. All scheduling is done from among tasks in the active queues structure. When the active queues structure is empty, a simple pointer assignment results in a switch of the active and expired queues, and scheduling continues. Scheduling is simple and efficient. On a given processor, the scheduler picks the highest-priority nonempty queue. If multiple tasks are in that queue, the tasks are scheduled in round-robin fashion. Linux also includes a mechanism for moving tasks from the queue lists of one processor to that of another. Periodically, the scheduler checks to see if there is a substantial imbalance among the number of tasks assigned to each processor. To balance the load, the schedule can transfer some tasks. The highest-priority active tasks are selected for transfer, because it is more important to distribute high-priority tasks fairly.
9/29/2015
Advance Tools and Technologies (and Problem Solving)
49
UNIX FreeBSD Scheduler
9/29/2015
Advance Tools and Technologies (and Problem Solving)
50
FreeBSD scheduler was designed to provide effective scheduling for a SMP or multicore system
Design goals:
address the need for processor affinity in SMP and multicore systems
processor affinity – a scheduler that only migrates a thread when necessary to avoid having an idle processor
provide better support for multithreading on multicore systems
improve the performance of the scheduling algorithm so that it is no longer a function of the number of threads in the system
9/29/2015
Advance Tools and Technologies (and Problem Solving)
51
• Priorities in Windows are organized into two bands or classes: real time priority class • all threads have a fixed priority that never changes • all of the active threads at a a given priority level are in a round-robin queue variable priority class • a thread’s priority begins an initial priority value and then may be temporarily boosted during the thread’s lifetime
• Each band consists of 16 priority levels • Threads requiring immediate attention are in the real-time class • include functions such as communications and real-time tasks
9/29/2015
Advance Tools and Technologies (and Problem Solving)
52
Windows Priority Relationship
Figure 10.15 9/29/2015
Advance Tools and Technologies (and Problem Solving)
53
Windows 8 ReFS • • • • •
It is resilient file system Introduced in 2012 Intended for file server Improve NTFS Maximizes reliability, data availability, data integrity
9/29/2015
Advance Tools and Technologies (and Problem Solving)
54
Goals of ReFS • • • •
Compatibility with NTFS Verify and autocorrect the data Optimize the extreme scale Code reusability
9/29/2015
Advance Tools and Technologies (and Problem Solving)
55
An Overview of Palm OS • Designed for special hardware – small screen ( 160 x 160 ) – less processing power than desktop PCs – quick turnaround expected – limited memory ( 512k ~ 8MB ) – no disk drive or PCMCIA disk
9/29/2015
Advance Tools and Technologies (and Problem Solving)
56
The Appearance of a PalmPilot
9/29/2015
Advance Tools and Technologies (and Problem Solving)
57
System Architecture
9/29/2015
Advance Tools and Technologies (and Problem Solving)
58
Memory Orgnization • Motorola 68328 uses 32-bit addresses • External data bus is only 16 bits wide • ROM - stores the main suite of applications ( the OS itself) • RAM - stores additional and replacement applications & system extensions • RAM - dynamic RAM & storage RAM
9/29/2015
Advance Tools and Technologies (and Problem Solving)
59
Developing Apps on Palm • Various development tools: – Code Warrior for Palm OS – Palm SDK (header files, documents, examples) – GCC – POSE - An open source Palm emulator runs on Windows, Mac and UNIX
9/29/2015
Advance Tools and Technologies (and Problem Solving)
60
PalmOS • The Palm OS provides a good platform for developing Palm apps • The Palm OS provides various libraries for communicating with PC’s • A good OS design is not necessarily having the most advanced feature, but having the best integration of the hardware
9/29/2015
Advance Tools and Technologies (and Problem Solving)
61
Microsoft Windows CE 5.0 • Specially designed for mobile and embedded systems • Closed source OS written in C • Based on hybrid kernel • It is 32bit multitasking, multithreading
9/29/2015
Advance Tools and Technologies (and Problem Solving)
62
Windows CE 5.0 Memory Model • Virtual Memory Map – 2 GB for Kernel – Single 2 GB mapping for all processes • Divided up into 32 MB “slots”
• 32 Process Limit – Each process has one 32 MB slot – 32 slots for processes
• Shared memory – Upper half of user space is shared memory Advance Tools and Technologies (and – Read / Write by all processes 9/29/2015 Problem Solving)
63
Windows CE 5.0 Memory Model 2 GB Kernel Space
Kernel
Shared Memory
Single 2 GB VM for all Processes
9/29/2015
Slot 32 Slot 31 : : Slot 7 Slot 6 – Explorer.exe Slot 5 – Services.exe Slot 4 – GWES.exe Slot 3 – Device.exe Slot 2 – FileSys.exe SlotAdvance 1 – ROM Tools DLLs and Technologies (and Slot 0 – Execution
Problem Solving)
32 Slots for Processes Execution Slot and Shared DLL Slot
64
Google Android • Developed by Android INC, but purchased by Google • It is open source • Based on Linux 2.6 • Developed using assembly language,C,C++,Java • Low power devices • Apps are written in Java
9/29/2015
Advance Tools and Technologies (and Problem Solving)
65
Android Features • • • • • • • •
Application Framework Dalvik virtual machine Integrated (webkit) browser 2D and 3D graphics APIs with HW SQLite Video and audio codecs Bluetooth, EDGE, 3G, and WiFi Camera, GPS, compass, and accelerometer
9/29/2015
Advance Tools and Technologies (and Problem Solving)
66
Android architecture
Challenges • • • •
CPU typically runs 500-600 Mhz RAM available to an App may only be a few megabytes Disk (flash) access is very slow Lifecycle - apps must pause/quit often, and restore to give the illusion that they are always running • UI design o typical screen may be HVGA (320x480) o may be in portrait or landscape o very high DPI - small text may not be readable o touch resolution is very low (~25 pixel) • Network access may be slow and (very) intermittent
9/29/2015
Advance Tools and Technologies (and Problem Solving)
68
Opportunities • 100s of millions of mobile phone users • Very high growth, esp. in Asia • "Wild wild west" of application development o think 1985 on the desktop (if you were born by then) o no dominant 3rd party developers.... yet o what will the killer app categories be? o what does it mean to have any app + the internet in your pocket? • You can develop for it today!
9/29/2015
Advance Tools and Technologies (and Problem Solving)
69
Important questions 1. What is real time system? State and explain its types.
2. What is rate monotonic scheduling? Explain with example. 3. Write short notes on 1) Fail soft operation 2) Frame of reference for handheld system. 4. Write a short note on handheld devices a) Palm OS b) Google Android c) Windows Mobile
5. Explain data structures used in Linux scheduling. 6. Enlist different characteristics of real time system and explain. 9/29/2015
Advance Tools and Technologies (and Problem Solving)
70
Important questions 7. Explain static priority-driven preemptive approach for real time scheduling. 8. Compare Windows NTFS and ReFS file systems 9. Draw and explain Android OS architecture. 10. Explain static table-driven approach for real time scheduling. 11. Explain static priority-driven preemptive approach for real time scheduling.
9/29/2015
Advance Tools and Technologies (and Problem Solving)
71
Important questions 12. What is deadline scheduling? Explain with example. 13. What is embedded system? List its characteristics and examples. 14. Explain the design issues of multiprocessor scheduling.
9/29/2015
Advance Tools and Technologies (and Problem Solving)
72
Thank you Personal website: http://www.pavanjaiswal.com
9/29/2015
Advance Tools and Technologies (and Problem Solving)
73