OS Examples




Operating System Examples

We turn next to a description of the scheduling policies of the Solaris, Windows XP, and Linux operating systems. It is important to remember that we are describing the scheduling of kernel threads with Solaris and Linux. Recall that Linux does not distinguish between processes and threads; thus, we use the term task when discussing the Linux scheduler.

Example:

 Solaris Scheduling Solaris uses priority-based thread scheduling. It has defined four classes of scheduling, which are, in order of priority:

Topics You May Be Interested In
System Calls An Example: Networking
File System Mounting Environmental Subsystems
Swap Space Management Networking In Windows Xp
Thread Scheduling Windows Xp- History
Design Principles What Is Concurrency Control?

1. Real timeSystem

2. Time sharing

3. Interactive Within each class there are different priorities and different scheduling algorithms. Solaris scheduling is illustrated in Figure 5.10.

OS Examples

Topics You May Be Interested In
System Calls Swap Space Management
Monitors Environmental Subsystems
File Concept Rc 4000
Deadlock Avoidance Windows Xp- History
Deadlock Recovery Summary Of Os Structures

The default scheduling class for a process is time sharing. The scheduling policy for time sharing dynamically alters priorities and assigns time slices of different lengths using a multilevel feedback queue. By default, there is an inverse relationship between priorities and time slices: The higher the priority, the smaller the time slice; and the lower the priority, the larger the time slice. Interactive processes typically have a higher priority;

OS Examples

CPU-bound processes, a lower priority. This scheduling policy gives good response time for interactive processes and good throughput for CPU-bound processes. The interactive class uses the same scheduling policy as the time-sharing class, but it gives windowing applications a higher priority for better performance. Figure 5.11 shows the dispatch table for scheduling interactive and timesharing threads. These two scheduling classes include 60 priority levels, but for brevity, we display only a handful.

The dispatch table shown in Figure 5.11 contains the following fields:

Topics You May Be Interested In
Batch Operating Systems Semaphore In Operation System
Layered Architecture Of Operating System Mass Storage Structure Overview
Direct Memory Access Disk Scheduling
System Calls Transforming I/o Requests To Hardware Operations
Threads Overview Mutual Exclusion

• Priority. The class-dependent priority for the time-sharing and interactive classes. A higher number indicates a higher priority.

 • Time quantum. The time quantum for the associated priority. This illustrates the inverse relationship between priorities and time quanta:

OS Examples

The lowest priority (priority 0) has the highest time quantum (200 milliseconds), and the highest priority (priority 59) has the lowest time quantum (20 milliseconds). Time quantum expired. The new priority of a thread that has used its entire time quantum without blocking. Such threads are considered CPU-intensive. As shown in the table, these threads have their priorities lowered. Return from sleep. The priority of a thread that is returning from sleeping (such as waiting for I/O).

Topics You May Be Interested In
Time Sharing Operating Systems Memory Mapped Files
Multiprocessor Systems Revocation Of Access Rights
Copy On Write An Example-windows Xp
Computing Environments- Traditional Computing, Client-server Computing, Peer-to-peer Computing, Web-based Computing Explain Reaching Agreement.
Atomicity Distributed System-motivation

As the table illustrates, when I/O is available for a waiting thread, its priority is boosted to between 50 and 59, thus supporting the scheduling policy of providing good response time for interactive processes. Solaris 9 introduced two new scheduling classes: fixed priority and fair share. Threads in the fixed-priority class have the same priority range as those in the time-sharing class; however, their priorities are not dynamically adjusted. The fair-share scheduling class uses CPU shares instead of priorities to make scheduling decisions. CPU shares indicate entitlement to available CPU resources and are allocated to a set of processes (known as a project).

Solaris uses the system class to run kernel processes, such as the scheduler and paging daemon. Once established, the priority of a system process does not change. The system class is reserved for kernel use (user processes running in kernel mode are not in the systems class).

Threads in the real-time class are given the highest priority. This assignment allows a real-time process to have a guaranteed response from the system within a bounded period of time. A real-time process will run before a process in any other class. In general, however, few processes belong to the real-time class. Each scheduling class includes a set of priorities. However, the scheduler converts the class-specific priorities into global priorities and selects the thread with the highest global priority to run. The selected thread runs on the CPU until it (1) blocks, (2) uses its time slice, or (3) is preempted by a higher-priority thread. If there are multiple threads with the same priority, the scheduler uses a round-robin queue. As mentioned, Solaris has traditionally used the manyto-many model (4.2.3) but with Solaris 9 switched to the one-to-one model (4.2.2).

 Example:

Topics You May Be Interested In
Hybrid Architecture Of Operating System Linux History
Interprocess Communication The Operating System
Multithreading Models How Is Cpu Scheduling Done In Multimedia Systems?
Operating System Services What Is Vxworks 5.x?
Robustness Mutual Exclusion

Windows XP Scheduling

Windows XP schedules threads using a priority-based, preemptive scheduling algorithm. The Windows XP scheduler ensures that the highest-priority thread will always run. The portion of the Windows XP kernel that handles scheduling is called the dispatcher. A thread selected to run by the dispatcher will run until it is preempted by a higher-priority thread, until it terminates, until its time quantum ends, or until it calls a blocking system call, such as for I/O. If a higher-priority real-time thread becomes ready while a lower-priority thread is running, the lower-priority thread will be preempted. This preemption gives a real-time thread preferential access to the CPU when the thread needs such access. The dispatcher uses a 32-level priority scheme to determine the order of thread execution. Priorities are divided into two classes.

OS Examples

The variable class contains threads having priorities from 1 to 15, and the real-time class contains threads with priorities ranging from 16 to 31. (There is also a thread running at priority 0 that is used for memory management.) The dispatcher uses a queue for each scheduling priority and traverses the set of queues from highest to lowest until it finds a thread that is ready to run. If no ready thread is found, the dispatcher will execute a special thread called the idle thread. There is a relationship between the numeric priorities of the Windows XP kernel and the Win32 API. The Win32 API identifies several priority classes to which a process can belong. These include:

Topics You May Be Interested In
Time Sharing Operating Systems Special Purpose Systems
Process Scheduling Thread Libraries
Computer System Organization Xds-940
Multithreading Models Networking In Windows Xp
Segmentation How Is Cpu Scheduling Done In Multimedia Systems?

• REALTIME-PRIORITY_CLASS

 • HIGH-PRIORITY-CLASS

• ABOVE_NORMAL.PRIORITY_CLASS

• NORMAL-PRIORITY-CLASS

Topics You May Be Interested In
Os Design And Implementation How Is Cpu Scheduling Done In Multimedia Systems?
Deadlock Recovery Explain Reaching Agreement.
File Replication Event Ordering
Thread Scheduling Atomic Transactions
Application I/o Interface Summary Of Os Structures

• BELOW.NORMAL_PRIORITY-CLASS

 • IDLE-PRIORITY-CLASS Priorities in all classes except the REALTIME-PRIORITY-CLASS are variable, meaning

Within each of the priority classes is a relative priority. The values for relative priority include: • TIMEJZRITICAL

 • HIGHEST

Topics You May Be Interested In
Microkernel Architecture Of Operating System An Example-windows Xp
System Boot An Example: Cineblitz
Operating System Services User Authentication
Atomicity What Is Multics?
Revocation Of Access Rights Programmer Interface

• ABOVE-NORMAL

• NORMAL

 • BELOW-NORMAL

 • LOWEST

Topics You May Be Interested In
System Programs Virtual Machines
Operating System Operations- Dual-mode Operation, Timer Log-structured File Systems
Threads Overview An Example: Networking
Thrashing I/o Performance
Systems Analysis And Design: Core Concepts Multimedia- Network Management

 • IDLE

The priority of each thread is based on the priority class it belongs to and its relative priority within that class. This relationship is shown in Figure 5.12. The values of the priority classes appear in the top row. The left column contains the values for the relative priorities. For example, if the relative priority of a thread in the ABOVE.NORMAL_PRIORITY_CLASS is NORMAL, the numeric priority of that thread is 10. Furthermore, each thread has a base priority representing a value in the priority range for the class the thread belongs to. By default, the base priority is the value of the NORMAL relative priority for that specific class. The base priorities for each priority class are:

• REALTIME-PRIORTTY-CLASS—24 • HIGH_PRIORITY-CLASS—13 • ABOVE-NORM AL.PRIORJTY-CLASS—10 • NORMAL-PRIORITY.CLASS—8 • BELOW.NORMAL_PRIORITY_CLASS—6 • IDLE-PRIORITY-CLASS—4

Processes are typically members of the NORMAL .PRIORITY-CLASS. A process will belong to this class unless the parent of the process was of the IDLE-PRIORITY-CLASS or unless another class was specified when the process was created. The initial priority of a thread is typically the base priority of the process the thread belongs to. When a thread's time quantum runs out, that thread is interrupted; if the thread is in the variable-priority class, its priority is lowered.

Topics You May Be Interested In
Interprocess Communication What Is Ibm Os/360?
Multithreading Models The Mach Operating System
Operating System Services Features Of Real-time Kernels
Stateful Versus Stateless Service What Is Vxworks 5.x?
Disk Scheduling In Multimedia Systems Introduction To Storage Management

The priority is never lowered below the base priority, however. Lowering the thread's priority tends to limit the CPU consumption of compute-bound threads. When a variable-priority thread is released from a wait operation, the dispatcher boosts the priority. The amount of the boost depends on what the thread was waiting for; for example, a thread that was waiting for keyboard I/O would get a large increase, whereas a thread waiting for a disk operation would get a moderate one. This strategy tends to give good response times to interactive threads that are using the mouse and windows. It also enables I/O-bound threads to keep the I/O devices busy while permitting compute-bound threads to use spare CPU cycles in the background.

This strategy is used by several time-sharing operating systems, including UNIX. In addition, the window with which the user is currently interacting receives a priority boost to enhance its response time. When a user is running an interactive program, the system needs to provide especially good performance for that process. For this reason, Windows XP has a special scheduling rule for processes in the NORMAL_PR1ORITY_CLASS. Windows XP distinguishes between the foreground process that is currently selected on the screen and the background processes that are not currently selected. When a process moves into the foreground, Windows XP increases the scheduling quantum by some factor—typically by 3. This increase gives the foreground process three times longer to run before a time-sharing preemption occurs. 5.6.3 Example: Linux Scheduling Prior to version 2.5, the Linux kernel ran a variation of the traditional UNIX scheduling algorithm.

 Two problems with the traditional UNIX scheduler are that it does not provide adequate support for SMP systems and that it does not scale well as the number of tasks on the system grows. With version 2.5, the scheduler was overhauled, and the kernel now provides a scheduling algorithm that runs in constant time—known as O(l)—regardless of the number of tasks on the system. The new scheduler also provides increased support for SMP, including processor affinity and load balancing, as well as providing fairness and support for interactive tasks. The Linux scheduler is a preemptive, priority-based algorithm with two separate priority ranges: a real-time range from 0 to 99 and a nice value ranging from 100 to 140. These two ranges map into a global priority scheme whereby numerically lower values indicate higher priorities. Unlike schedulers for many other systems, including Solaris (5.6.1) and Windows XP (5.6.2), Linux assigns higher-priority tasks longer time quanta and lower-priority tasks shorter time quanta. The relationship between priorities and time-slice length is shown in Figure 5.13.

OS Examples

Topics You May Be Interested In
Computing Environments- Traditional Computing, Client-server Computing, Peer-to-peer Computing, Web-based Computing I/o Performance
System Model Linux History
Revocation Of Access Rights What Is Multimedia?
Communication Protocols What Is Multics?
An Example: Networking Programmer Interface

A runnable task is considered eligible for execution on the CPU as long as it has time remaining in its time slice. When a task has exhausted its time slice, it is considered expired and is not eligible for execution again until all other tasks have also exhausted their time quanta. The kernel maintains a list of all runnable tasks in a runqueue data structure. Because of its support for SMP, each processor maintains its own runqueue and schedules itself independently. Each runqueue contains two priority arrays—active and expired. The active array contains all tasks with time remaining in their time slices, and the expired array contains all expired tasks.

Each of these priority arrays contains a list of tasks indexed according to priority (Figure 5.14).

OS Examples

The scheduler chooses the task with the highest priority from the active array for execution on the CPU. On multiprocessor machines, this means that each processor is scheduling the highest-priority task from its own runqueue structure. When all tasks have exhausted their time slices (that is, the active array is empty), the two priority arrays are exchanged; the expired array becomes the active array, and vice versa. Linux implements real-time scheduling as defined by POSIX.lb, which is fully described in Section 5.5.2. Real-time tasks are assigned static priorities. All other tasks have dynamic priorities that are based on their nice values plus or minus the value 5. The interactivity of a task determines whether the value 5 will be added to or subtracted from the nice value. A task's interactivity is determined by how long it has been sleeping while waiting for I/O. Tasks that are more interactive typically have longer sleep times and therefore are more likely to have adjustments closer to -5, as the scheduler favors interactive tasks. The result of such adjtistments will be higher priorities for these tasks. Conversely, tasks with shorter sleep times are often more CPU-bound and thus will have their priorities lowered. The recalculation of a task's dynamic priority occurs when the task has exhausted its time quantum and is to be moved to the expired array. Thus, when the two arrays are exchanged, all tasks in the new active array have been assigned new priorities and corresponding time slices.

Topics You May Be Interested In
Real Time Operating System Memory Mapped Files
Hybrid Architecture Of Operating System File System-recovery
Paging In Operating System User Authentication
Free Space Management What Is The Security Problem?
Thread Scheduling What Is Multics?


Frequently Asked Questions

+
Ans: When a process running in user mode requests additional memory, pages are allocated from the list of free page frames maintained by the kernel. This list is typically populated using a page-replacement algorithm such as those discussed in Section 9.4 and most likely contains free pages scattered throughout physical memory, as explained earlier. Remember, too, that if a user process requests a single byte of memory, internal fragmentation will result, as the process will be granted, an entire page frame. Kernel memory, however, is often allocated from a free-memory pool different from the list used to satisfy ordinary user-mode processes. view more..
+
Ans: Thrashing If the number of frames allocated to a low-priority process falls below the minimum number required by the computer architecture, we must suspend, that process's execution. We should then page out its remaining pages, freeing all its allocated frames. This provision introduces a swap-in, swap-out level of intermediate CPU scheduling. In fact, look at any process that does not have ''enough" frames. If the process does not have the number of frames it needs to support pages in active use, it will quickly page-fault. At this point, it must replace some page. However, since all its pages are in active use, it must replace a page that will be needed again right away. Consequently, it quickly faults again, and again, and again, replacing pages that it must bring back in immediately. This high paging activity is called thrashing. A process is thrashing if it is spending more time paging than executing. view more..
+
Ans: Demand Paging Consider how an executable program might be loaded from disk into memory. One option is to load the entire program in physical memory at program execution time. However, a problem with this approach, is that we may not initially need the entire program in memory. Consider a program that starts with a list of available options from which the user is to select. Loading the entire program into memory results in loading the executable code for all options, regardless of whether an option is ultimately selected by the user or not. An alternative strategy is to initially load pages only as they are needed. This technique is known as demand paging and is commonly used in virtual memory systems. view more..
+
Ans: We turn next to a description of the scheduling policies of the Solaris, Windows XP, and Linux operating systems. It is important to remember that we are describing the scheduling of kernel threads with Solaris and Linux. Recall that Linux does not distinguish between processes and threads; thus, we use the term task when discussing the Linux scheduler. view more..
+
Ans: Overview of Mass-Storage Structure In this section we present a general overview of the physical structure of secondary and tertiary storage devices view more..
+
Ans: Allocation of Frames We turn next to the issue of allocation. How do we allocate the fixed amount of free memory among the various processes? If we have 93 free frames and two processes, how many frames does each process get? The simplest case is the single-user system. Consider a single-user system with 128 KB of memory composed of pages 1 KB in size. This system has 128 frames. The operating system may take 35 KB, leaving 93 frames for the user process. Under pure demand paging, all 93 frames would initially be put on the free-frame list. When a user process started execution, it would generate a sequence of page faults. The first 93 page faults would all get free frames from the free-frame list. view more..
+
Ans: The direct-access nature of disks allows us flexibility in the implementation of files, in almost every case, many files are stored on the same disk. The main problem is how to allocate space to these files so that disk space is utilized effectively and files can be accessed quickly. Three major methods of allocating disk space are in wide use: contiguous, linked, and indexed. Each method has advantages and disadvantages. Some systems (such as Data General's RDOS for its Nova line of computers) support all three. view more..
+
Ans: Free-Space Management Since disk space is limited, we need to reuse the space from deleted files for new files, if possible. (Write-once optical disks only allow one write to any given sector, and thus such reuse is not physically possible.) To keep track of free disk space, the system maintains a free-space list. The free-space list records all free disk blocks—those not allocated to some file or directory. To create a file, we search the free-space list for the required amount of space and allocate that space to the new file. This space is then removed from the free-space list. view more..
+
Ans: File Concept Computers can store information on various storage media, such as magnetic disks, magnetic tapes, and optical disks. So that the computer system will be convenient to use, the operating system provides a uniform logical view of information storage. The operating system abstracts from the physical properties of its storage devices to define a logical storage unit, the file. Files are mapped by the operating system onto physical devices. These storage devices are usually nonvolatile, so the contents are persistent through power failures and system reboots. view more..
+
Ans: Modern disk drives are addressed as large one-dimensional arrays of logical blocks, where the logical block is the smallest unit of transfer. The size of a logical block is usually 512 bytes, although some disks can be low-level formatted to have a different logical block size, such as 1,024 bytes. view more..
+
Ans: In the previous sections, we explored the motivation for file sharing and some of the difficulties involved in allowing users to share files. Such file sharing is very desirable for users who want to collaborate and to reduce the effort required to achieve a computing goal. Therefore, user-oriented operating systems must accommodate the need to share files in spite of the inherent difficulties. In this section, we examine more aspects of file sharing view more..
+
Ans: When information is stored in a computer system, we want to keep it safe from physical damage (reliability) and improper access (protection). Reliability is generally provided by duplicate copies of files. Many computers have systems programs that automatically (or through computer-operator intervention) copy disk files to tape at regular intervals (once per day or week or month) to maintain a copy should a file system be accidentally destroyed. view more..
+
Ans: Goal of systems analysis and design is to improve organizational systems. This process involves developing or acquiring application software and training employees. view more..
+
Ans: Disk Scheduling One of the responsibilities of the operating system is to use the hardware efficiently. For the disk drives, meeting this responsibility entails having fast access time and large disk bandwidth. The access time has two major components. The seek time is the time for the disk arm to move the heads to the cylinder containing the desired sector. The rotational latency is the additional time for the disk to rotate the desired sector to the disk head. The disk bandwidth is the total number of bytes transferred, divided by the total time between the first request for service and the completion of the last transfer. We can improve both the access time and the bandwidth by scheduling the servicing of disk I/O requests in a good order. Whenever a process needs I/O to or from the disk, it issues a system call to the operating system view more..
+
Ans: The operating system is responsible for several other aspects of disk management, too. Here we discuss disk initialization, booting from disk, and bad-block recovery. view more..
+
Ans: File-System Structure Disks provide the bulk of secondary storage on which a file system is maintained. They have two characteristics that make them a convenient medium for storing multiple files: 1. A disk can be rewritten in place; it is possible to read a block from the disk, modify the block, and write it back into the same place. 2. A disk can access directly any given block of information it contains. Thus, it is simple to access any file either sequentially or randomly, and switching from one file to another requires only moving the read-write heads and waiting for the disk to rotate. view more..
+
Ans: An operating system provides an environment for the execution of programs. It provides certain services to programs and to the users of those programs. The specific services provided, of course, differ from one operating system to another, but we can identify common classes. These operating-system services are provided for the convenience of the programmer, to make the programming task easier. services are : User interface, Program execution, I/O operations, File-system manipulation, Communications, Error detection, Resource allocation, Accounting, Protection and security view more..
+
Ans: User Operating-System Interface There are two fundamental approaches for users to interface with the operating system. One technique is to provide a command-line interface or command interpreter that allows users to directly enter commands that are to be performed by the operating system. The second approach allows the user to interface with the operating system via a graphical user interface or GUI. view more..




Rating - 3/5
453 views

Advertisements