9 Chorus History of Chorus n n n

  • Slides: 42
Download presentation
9. Chorus

9. Chorus

History of Chorus n n n Chorus started out at the French research institute

History of Chorus n n n Chorus started out at the French research institute INRIA in 1980, as a research project in distributed systems. It has since gone through four versions, numbered from 0 through 3. The idea behind Version 0 was to model distributed applications as a collection of actors. Version 1, which lasted from 1982 to 1984, focused on multiprocessor research. Version 2 (1984 -1986) was a major rewrite of the system, in C. Version 3 was started in 1987. The version marked the transition from a research system to a commercial product.

Goals of Chorus 1. 2. 3. 4. High-performance UNIX emulation. Use on distributed systems.

Goals of Chorus 1. 2. 3. 4. High-performance UNIX emulation. Use on distributed systems. Real-time applications. Integrating object-oriented programming into Chorus.

System Structure UNIX subsystem Object-oriented subsystem u 1 User addr. space Kernel addr. space

System Structure UNIX subsystem Object-oriented subsystem u 1 User addr. space Kernel addr. space s 1 s 2 k 1 Microkernel u 2 u 3 User process s 3 System process k 2 Kernel process Management of names, processes, threads, memory, and communication.

Six key abstractions Address space Thread Port: holding incoming messages at any instant, each

Six key abstractions Address space Thread Port: holding incoming messages at any instant, each port belongs to one process. Microkernel message Region of address space Microkernel network

A capability in Chorus UI of a port key to distinguish objects Bits 13

A capability in Chorus UI of a port key to distinguish objects Bits 13 3 48 64 Creation site Type Epoch number + counter Defined by the subsystem Can indicate site, port, or port group; the other five combinations are reserved for future use.

An address space with four mapped regions Region stack Scratched segment Unmapped address Region

An address space with four mapped regions Region stack Scratched segment Unmapped address Region file Unmapped address Region data Region program Mapped portion of file F Unmapped portion of file F Copy of program’s initial data Read-only segment

Kernel structure Responsible for ports and messages Interprocess communication manager (portable) Handles, processes, threads,

Kernel structure Responsible for ports and messages Interprocess communication manager (portable) Handles, processes, threads, and Real-time executive scheduling (portable) Virtual memory (portable) Supervisor (machine dependent) Caches traps, interrupts, and exceptions Manages paging (low-level part of the paging system) Machine-dependent Portion of the virtua Memory manager

The UNIX Subsystem n n Since Chorus is now a commercial product, it must

The UNIX Subsystem n n Since Chorus is now a commercial product, it must be compatible with UNIX. Chorus accomplishes this goal by providing a standard subsystem, called Mi. X, that is compatible with System V. Mi. X is also compatible with UNIX in other ways. For example, the file system is compatible, so Chorus can read a UNIX disk. Furthermore, the Chorus device drivers are interface compatible with the UNIX ones, so if UNIX device drivers exist for a device machine, they can be ported to Chorus with relatively littler work.

The Object-Oriented Subsytem n It consists of three layers. The bottom layer does object

The Object-Oriented Subsytem n It consists of three layers. The bottom layer does object management in a generic way and is effectively a microkernel for objectoriented systems. The middle layer provides a general runtime system. The top layer is the language runtime system. This subsystem, called COOL.

Process Management in Chorus n A process in Chorus is a collection of active

Process Management in Chorus n A process in Chorus is a collection of active and passive elements that work together to perform some computation. The active elements are threads. The passive elements are an address space (containing some regions) and a collection of ports (for sending and receiving messages).

Three kinds of processes Type Trust Privilege Mode Space User Untrusted Unpriviledged User System

Three kinds of processes Type Trust Privilege Mode Space User Untrusted Unpriviledged User System Trusted Unpriviledged User Kernel Trusted Privileged User Kernel

n n Privilege refers to the ability to execute I/O and other protected instructions.

n n Privilege refers to the ability to execute I/O and other protected instructions. Trust means that the process is allowed to call the kernel directly.

Threads n n Every thread has its own private context (i. e. , stack,

Threads n n Every thread has its own private context (i. e. , stack, program counter, and registers). A thread is tied to the process in which it was created, and cannot be moved to another process. Chorus threads are known to the kernel and scheduled by the kernel, so creating and destroying them requires making kernel calls. An advantage of having kernel threads is that when one thread blocks waiting for some event (e. g. , a message arrival), the kernel can schedule other threads. Another advantage is the ability to run different threads on different CPUs when a multiprocessor is available.

n n The disadvantage of kernel threads is the extra overhead required to manage

n n The disadvantage of kernel threads is the extra overhead required to manage them. Threads communicate with one another by sending and receiving messages.

Chorus distinguishes the following states, but they are not mutually exclusive: 1. ACTIVE –

Chorus distinguishes the following states, but they are not mutually exclusive: 1. ACTIVE – The thread is logically able to run. 2. SUSPENDED – The thread has been intentionally suspended. 3. STOPPED – The thread’s process has been suspended. 4. WAITING – The thread is waiting for some event to happen. n

Two synchronization mechanisms n n Traditional semaphore, with operations UP and DOWN. mutex, which

Two synchronization mechanisms n n Traditional semaphore, with operations UP and DOWN. mutex, which is essentially a semaphore whose values are restricted to 0 and 1. Mutexes are used only for mutual exclusion.

Scheduling n n n CPU scheduling is done using priorities on a perthread basis.

Scheduling n n n CPU scheduling is done using priorities on a perthread basis. Each process has a priority and each thread has a relative priority within its process. The absolute priority of a thread is the sum of its process’ priority and its own relative priority. The kernel keeps track of the priority of each thread in ACTIVE state and runs the one with the highest absolute priority. On a multiprocessor with k CPUs, the k highest-priority threads are run.

High priority A These threads are not timesliced These threads are timesliced Low priority

High priority A These threads are not timesliced These threads are timesliced Low priority B C D D C

Traps, Exceptions, and Interrupts n 1. 2. Traps are intentional calls to the kernel

Traps, Exceptions, and Interrupts n 1. 2. Traps are intentional calls to the kernel or a subsystem to invoke services. Programs cause traps by calling a system call library procedure. The system supports two ways of handling traps. all traps for a particular trap vector go to a single kernel thread that has previously announced its willingness to handle that vector. each trap vector is tied to an array of kernel threads, with the Chorus supervisor using the contents of a certain register to index into the array to pick a thread.

n n Exceptions are unexpected events that are caused by accident, such as the

n n Exceptions are unexpected events that are caused by accident, such as the divide-byzero exception, floating-point overflow, or a page fault. Interrupts are caused by asynchronous events, such as clock ticks or the completion of an I/O request.

Kernel Calls for Process Management actor. Create a new process Actor. Delete Remove a

Kernel Calls for Process Management actor. Create a new process Actor. Delete Remove a process Actor. Stop actore. Start Stop a process, put its threads in STOPPED state Restart a process from STOPPED state actor. Priority Get or set a process’ priority actor. Except Get or set the port used for exception handling

thread. Create a new thread. Delete a thread. Suspend a thread. Resume Restart a

thread. Create a new thread. Delete a thread. Suspend a thread. Resume Restart a suspended thread. Priority Get or set a thread’s priority thread. Load Get a thread’s context pointer thread. Store Set a thread’s context pointer thread. Context Get or set a thread’s execution context

mutex. Initialize a mutex. Get Try to acquire a mutex. Release a mutex sem.

mutex. Initialize a mutex. Get Try to acquire a mutex. Release a mutex sem. Initialize a semaphore sem. P Do a DOWN on a semaphore sem. V Do an UP on a semaphore

Memory Management in Chorus n n A region is a contiguous range of virtual

Memory Management in Chorus n n A region is a contiguous range of virtual address, for example, from 1024 to 6143. A segment is a contiguous collection of bytes named and protected by a capability.

n n n Mapping segments onto regions. It is not necessary that a segment

n n n Mapping segments onto regions. It is not necessary that a segment be exactly the size of its region. 1. If the segment is larger than the region, only a portion of the segment will be visible in the address space, although which portion is visible can be changed by remapping it. 2. If the segment is smaller than the region, the result of reading an unmapped address is up to the mapper. For example, it can raise an exception, return 0, or extend the segment.

Mappers n Each mapper controls one or more segments that are mapped onto regions.

Mappers n Each mapper controls one or more segments that are mapped onto regions. A segment can be mapped into multiple regions, even in different address spaces at the same time.

Segments can be mapped into multiple address space at the same time Process A

Segments can be mapped into multiple address space at the same time Process A Segments S 1 S 2 Process B

Distributed Shared Memory n n Chorus supports paged distributed shard memory in the style

Distributed Shared Memory n n Chorus supports paged distributed shard memory in the style of IVY. IT uses a dynamic decentralized algorithm, meaning that different managers keep track of different pages, and the manager for a page change as the page moves around the system. The unit of sharing between multiple machines is the segment. Segments are split up into fragments of one or more pages. At any instant, each fragment is either read-only, and potentially present on multiple machines, or read/write, and present only on one machine.

Kernel Calls for Memory Management rgn. Allocate a memory region and set its properties

Kernel Calls for Memory Management rgn. Allocate a memory region and set its properties rgn. Free Release a previously allocated region rgn. Init Allocate a region and fill it from a given segment rgn. Set. Inherit Set the inheritance properties of a region rgn. Set. Paging Set the paging properties of a region rgn. Set. Protect Set the protection options of a region rgn. Stat Get the statistics associated with a region

sg. Read data from a segment sg. Write data to a segment sg. Stat

sg. Read data from a segment sg. Write data to a segment sg. Stat Request information about a page cache sg. Flush Request from a mapper to the kernel asking for dirty pages

Mp. Create Request to create a dummy segment for swapping Mp. Release Request asking

Mp. Create Request to create a dummy segment for swapping Mp. Release Request asking to release a previously created segment Mp. Pull. In Request asking for one or more pages Mp. Push. Out Request asking mapper to accept one or more pages

Communication in Chorus n The basic communication paradigm in Chorus is message passing. 64

Communication in Chorus n The basic communication paradigm in Chorus is message passing. 64 bytes long header An optional fixed part Identifies the source and destination and contains protection identifiers and flags. Maximum of 64 k bytes Optional body

Port group 1 Port group 2 network

Port group 1 Port group 2 network

Communication Operations n n n Two kinds of communication operations are provided by Chorus:

Communication Operations n n n Two kinds of communication operations are provided by Chorus: asynchronous send and RPC. Asynchronous send allows a thread simply to send a message to a port. There is no guarantee that the message arrives and no notification if something goes wrong. RPC uses blocking send at-most-once semantics.

To all 1 2 3

To all 1 2 3

To any 1 2 3

To any 1 2 3

To 1 1 2 3

To 1 1 2 3

Not to 1 1 2 3

Not to 1 1 2 3

Kernel calls for communication port. Create a port and return its capability port. Delete

Kernel calls for communication port. Create a port and return its capability port. Delete Destroy a port. Enable port. Disable Eanble a port so its messages count on a receive from all ports Disable a port. Migrate Move a port to a different process

grp. Allocate Create a port group grp. Port. Insert Add a new port to

grp. Allocate Create a port group grp. Port. Insert Add a new port to an existing port gro grp. Port. Remove Delete a port from a port group

ipc. Send a message asynchronously ipc. Receive Block until a message arrives ipc. Get.

ipc. Send a message asynchronously ipc. Receive Block until a message arrives ipc. Get. Data Get the current message’s body ipc. Reply Send a reply to the current message Perform a remote procedure call ipc. Call