OPERATING SYSTEM SUPPORT Introduction The Operating System Layer Protection Processes and Threads Communication and Invocation Operating System Architecture
Introduction Many distributed operating systems have been investigated, but there are none in general/wide use. But network operating system are in wide use for various reasons both technical and non-technical. Users have much invested in their application software; they will not adopt a new operating system that will not run their applications.
Introduction The second reason against the adoption of distributed operating system is that users tend to prefer to have a degree of autonomy for their machines, even in a organization. Unix and Windows are two examples of network operating systems. Those have a networking capability built into them and so can be used to access remote resources using basic services such as rlogin and telnet.
Introduction The combination of middleware and network operating systems provides an acceptance balance between the requirement of autonomy and network transparency. The network operating systems allows users to run their favorite word processor and other standalone applications.
The Operating System Layer Figure 1. System layers
The Operating System Layer Figure 1 shows how the operating system layer at each of two nodes supports a common middleware layer in providing a distributed infrastructure for applications and services. Kernels and server processes are the components that manage resources and present clients with an interface to the resources.
The Operating System Layer The OS facilitates: Encapsulation Protection Concurrent processing Invocation mechanism is a means of accessing an encapsulated resource.
The Operating System Layer Figure 2. Core OS functionality
Process Manager: handles the creation of and operations upon processes. Thread manager: Thread Creation, Synchronization and Scheduling. Threads are schedulable activities attached to processes Communication Manager: manages communication between threads attached to different processes on the same computer. Communication between threads in remote processes. Memory Manager: management of physical and virtual memory Supervisor: Dispatching of interrupts, system call traps and other exceptions; control of memory management unit and hardware caches. Processor and floating point unit register manipulations.
Protection Resources require protection from illegitimate access File protection by providing access privileges Hardware supports to protect modules: hard lock Kernel can control the memory management unit and set of processor registers so that no other code may access the machine’s physical resources except in acceptable way.
Process Processes and Threads A process consists of an execution environment together with one or more threads. A thread is the operating system abstraction of an activity. An execution environment is the unit of resource management: a collection of local kernel managed resources to which its threads have access.
Processes and Threads An execution environment consists of : An address space Thread synchronization and communication resources (e.g., semaphores, sockets) Higher-level resources (e.g., file systems, windows)
Threads Processes and Threads Threads are schedulable activities attached to processes. The aim of having multiple threads of execution is : To maximize degree of concurrent execution between operations To enable the overlap of computation with input and output To enable concurrent processing on multiprocessors.
Processes and Threads Processes vs. Threads Threads can be helpful within servers: Concurrent processing of client’s requests can reduce the tendency for servers to become bottleneck. E.g. one thread can process a client’s request while a second thread serving another request waits for a disk access to complete. Processes vs. Threads Threads are “lightweight” processes, processes are expensive to create but threads are easier to create and destroy.
Threads programming Processes and Threads Thread programming is concurrent programming. Java provides methods for creating, destroying and synchronizing threads. The Java thread class includes the constructor and management methods listed in Figure 3. The thread and object synchronization methods are in Figure 4.
Processes and Threads Thread(ThreadGroup group, Runnable target, String name) Creates a new thread in the SUSPENDED state, which will belong to group and be identified as name; the thread will execute the run() method of target. setPriority(int newPriority), getPriority() Set and return the thread’s priority. run() A thread executes the run() method of its target object, if it has one, and otherwise its own run() method (Thread implements Runnable). start() Change the state of the thread from SUSPENDED to RUNNABLE. sleep(int millisecs) Cause the thread to enter the SUSPENDED state for the specified time. yield() Enter the READY state and invoke the scheduler. destroy() Destroy the thread. Figure 3. Java thread constructor and management methods
Processes and Threads Figure 4. Java thread synchronization calls thread.join(int millisecs) Blocks the calling thread for up to the specified time until thread has terminated. thread.interrupt() Interrupts thread: causes it to return from a blocking method call such as sleep(). object.wait(long millisecs, int nanosecs) Blocks the calling thread until a call made to notify() or notifyAll() on object wakes the thread, or the thread is interrupted, or the specified time has elapsed. object.notify(), object.notifyAll() Wakes, respectively, one or all of any threads that have called wait() on object. Figure 4. Java thread synchronization calls
Processes and Threads Programs can manage threads in groups. Every thread belongs to one group assigned at thread creation time. thread groups are useful to shield various applications running in parallel on one Java Virtual Machine (JVM). A thread in one group cannot perform management operations on a thread in another group. E.g., an application thread may not interrupt a system windowing (AWT) thread.
Thread synchronization Processes and Threads Thread synchronization The main difficult issues in multi-threaded programming are the sharing of objects and the techniques used for thread coordination and cooperation. Each thread’s local variables in methods are private to it. Threads have private stack. Threads do not have private copies of static (class) variables or object instance variables.
Processes and Threads Java provides the synchronized keyword for thread coordination. any object can only be accessed through one invocation of any of its synchronized methods. an object can have synchronized and non-synchronized methods. example synchronized addTo() and removeFrom() methods to serialize requests in worker pool example.
Processes and Threads Threads can be blocked and woken up example The thread awaiting a certain condition calls an object’s wait() method. The other thread calls notify() or notifyAll() to awake one or all blocked threads. example When a worker thread discovers that there are no requests to process, it calls wait() on the instance of Queue. When the I/O thread adds a request to the queue, it calls the queue’s notify() method to wake up the worker.
Client and server with threads N threads Input-output Client Thread 2 makes T1 Thread 1 requests to server generates results Requests Receipt & queuing
Communication and Invocation RMI, RPC, Events/Notifications Review OS Communication: what, which protocols Communication Primitive: doOperation, getRequest and sendReply Protocols and Openness: most OS in 1980s incorporated their own network protocols tuned to RPC interactions
Invocation Performance Client and Server may make many millions of invocation related operations in their life times. However the network bandwidth improves invocation times have not decreased in proportion. NULL RPC is defined as an RPC without parameters that executes a null procedure and returns no values. Its execution involves an exchange of messages carrying some system data but not user data.
Invocation Performance Null Invocation costs are important because they measure a fixed overhead, the latency. Invocation cost increase with the size of arguments and results, but in many cases the latency is significant compared with the remainder of delay. RPC bandwidth/throughput is also concern when data has to be transferred in bulk.
Invocation Performance Marshalling: and unmarshalling which involve copying and converting data become significant when amount of data grows. Data copying: message data is copied several times in the course of RPC like from across the user-kernel boundary, across each protocol layer, between network interface and kernel buffers. Packet initialization: initializing protocol headers and trailers including checksums Thread Scheduling and Context switching
Operating System Architecture The major kernel architectures: Monolithic kernels Micro-kernels Monolithic Kernels A monolithic kernel can contain some server processes that execute within its address space, including file servers and some networking. The code that these processes execute is part or the standard kernel configuration. (Figure 5)
Operating System Architecture Microkernel The microkernel appears as a layer between hardware layer and a layer consisting of major systems. If performance is the goal, rather than portability, then middleware may use the facilities of the microkernel directly. (Figure 6)
Operating System Architecture Figure 5. Monolithic kernel and microkernel
Operating System Architecture Figure 6. The role of the microkernel
Operating System Architecture Monolithic and Microkernel comparison The advantages of a microkernel extensibility Its ability to enforce modularity behind memory protection boundaries. Its small kernel has less complexity. The advantages of a monolithic The relative efficiency with which operations can be invoked because even invocation to a separate user-level address space on the same node is more costly.
Operating System Architecture Hybrid Approaches Pure microkernel operating system such as Chorus & Mach have changed over a time to allow servers to be loaded dynamically into the kernel address space or into a user-level address space. In some operating system such as SPIN, the kernel and all dynamically loaded modules grafted onto the kernel execute within a single address space.
Operating System Architecture An open distributed system should make it possible to: Run only that system software at each computer that is necessary for its particular role in the system architecture. For example, system software needs for PDA and dedicated server are different. Loading redundant modules wastes memory resources. Allow the software (and the computer) implementing any particular service to be changed independent of other facilities.
Operating System Architecture Allow for alternatives of the same service to be provided, when this is required to suit different users or applications. Introduce new services without harming the integrity of existing ones.
Operating System Architecture A guiding principle of operating system design: The separation of fixed resource management “mechanisms“ from resource management “policies”, which vary from application to application and service to service. For example, an ideal scheduling system would provide mechanisms that enable a multimedia application such as videoconferencing to meet its real-time demands while coexisting with a non-real-time application such as web browsing.
Operating System Architecture The kernel would provide only the most basic mechanisms upon which the general resource management tasks at a node are carried out. Server modules would be dynamically loaded as required, to implement the required resource management policies for the currently running applications.