The Great Symbian

Anything under the sun goes here!

  • Thread Library schedules user-level threads to run on LWP
  • Thread management done by user-level Threads Library
  • The Thread Library is responsible for scheduling user threads on the available schedulable entities; this makes context switching of threads very fast, as it avoids system calls. However, this increases complexity and the likelihood of priority inversion, as well as suboptimal scheduling without extensive (and expensive) coordination between the userland scheduler and the kernel scheduler.

MANY-TO-ONE MODEL

• Many user-level threads mapped to single kernel thread.

• Used on systems that do not support kernel threads.




ONE-TO-ONE MODEL

• Each user-level thread maps to kernel thread.
• Creating a user thread requires creating the corresponding kernel thread.

• Windows NT/2000, OS/2




MANY-TO-MANY MODEL

• Allows many user level threads to be mapped to many kernel threads.

• Allows the operating system to create a sufficient number of kernel threads.

• Solaris 2 , IRIS, HP-UX










• Supported by the Kernel

• Slower to create and manage threads than are user threads

• If a thread performs a blocking system call, then the kernel can schedule another thread in the application for execution.• Multiple threads are able to run in parallel on multiprocessors.

• Examples
- Windows NT/2000
- Solaris 2
- Tru64 UNIX
- BeOS
- Linux

• Thread management done by user-level threads library

• Fast to create and manage threads

• If the kernel is single-threaded, then any user-level thread performing a blocking system call

will cause the entire process to block

• No need for kernel intervention

• Drawback : all may run in single process. If one blocks, all block.

• Examples
- POSIX Pthreads
- Mach C-treads
- Solaris UI-threads

  • Responsiveness

- Can run even if one thread blocked or bus

- Web browser example – one thread per client

  • Resource Sharing
  • Economy

- Creating and context switching threads is low cost

- Solaris 2 : creating 30x, context switch 5x slower for procs

  • Utilization of MP ArchitecturesF Run each thread on different CPU


  • A thread, also called a lightweight process (LWP), is the basic unit of CPU utilization.

  • It has its own program counter, a register set, and stack space.

  • It shares with the pear threads its code section, data section, and OS resources such as open files and signals, collectively called a task.

  • Single-threaded process has one program counter specifying location of next instexecuteO Process executes instructions sequentially, one at a time, until completion
  • Multi-threaded process has one program counter per thread

• Mechanism for processes to communicate and to synchronize
their actions.

• Message system – processes communicate with each other
without resorting to shared variables.

IPC facility provides two operations:
– send(message) – message size fixed or variable
– receive(message)

• If P and Q wish to communicate, they need to:
– establish a communication link between them
– exchange messages via send/receive

• Implementation of communication link
– physical (e.g., shared memory, hardware bus)
– logical (e.g., logical properties)


DIRECT COMMUNICATION

• Processes must name each other explicitly:
– Symmetric Addressing
• Send (P, message) – send to process P
• Receive(Q, message) – receive from Q
Asymmetric Addressing
•send (P, message) – send to process P
•receive(id, message) – rx from any; system sets id = sender
•Primitives:

–send(A, message) – send a message to mailbox A
–receive(A, message) – receive a message from mailbox A

•Properties of Communication Link
–Links established automatically between pairs
–processes must know each others ID
–Exactly one link per pair of communicating processes

•Disadvantage: a process must know the name or ID of the process(es) it wishes to communicate with


INDIRECT COMMUNICATION

• Messages are directed and received from mailboxes(also referred to as ports).
- Each mailbox has a unique id.
- Processes can communicate only if they share a mailbox.

• Properties of communication link
- Link established only if processes share a common mailbox
- A link may be associated with many processes.
- Each pair of processes may share several communicationlinks.
- Link may be unidirectional or bi-directional.
• Operations
- create a new mailbox
- send and receive messages through mailbox
- destroy a mailbox

• Primitives are defined as:
send a message to mailbox Areceive(A, message)
receive a message from mailbox A

• Mailbox sharingF P1, P2, and P3 share mailbox A.
- P1, sends; P2 and P3 receive.
- Who gets the message?

• Solutions
- Allow a link to be associated with at most two processes.
- Allow only one process at a time to execute a receiveoperation.
-Allow the system to select arbitrarily the receiver. Sender is notified who the receiver was.


SYNCHRONIZATION

• Message passing may be either blocking or non-blocking.

Blocking Send: sender blocked until message received by mailbox or process
Nonblocking Send: sender resumes operation immediately after sending
Blocking Receive: receiver blocks until a message is available
Nonblocking Receive: receiver returns immediately with either a valid or null message.

• Blocking is considered synchronous

• Non-blocking is considered asynchronous

• Send and receive primitives may be either blocking or non-blocking.

BUFFERING


• All messaging system require framework to temporarily buffer messages. These queues are implemented in one of three ways:

1.)Zero Capacity – 0 messages
Sender must wait for receiver (rendezvous).

2.) Bounded Capacity – finite length of n messages
Sender must wait if link full.

3.) Unbounded Capacity – infinite lengthSender never waits.

PRODUCER-CONSUMER EXAMPLE

• One process generates data – the producer

• The other process uses it – the consumer

• If directly connected – time coordination

- How would they coordinate the time ??




• One process generates data – the producer

• The other process uses it – the consumer

• If not directly connected – have a buffer

- Buffer must be accessible to both

- Finite Capacity N – Number in use - K










FEEDS

Add to Google Reader or Homepage

Click2Sell

Buy

How To Learn Photoshop in Just 2 Hrs

Chatbox

Click Here

About this blog