Operating System Support
• The OS must provide:
- Encapsulation
- Concurrent Processing
- Protection
• OS components:
- Process Manager
- Thread Manager
- Communication Manager
- Memory Manager
- Supervisor
Communication
manager
Threadmanager Memorymanager
Supervisor
Process manager
1
Isha Padhy, Department of CSE,CBIT,
Hyderabad
Operating System Layer
Applications, services
Computer &
Platform
Middleware
OS: kernel,
libraries &
servers
networkhardware
OS1
Computer &
networkhardware
Node 1 Node 2
Processes, threads,
communication, ...
OS2
Processes, threads,
communication, ...
2
Isha Padhy, Department of CSE,CBIT,
Hyderabad
Process/Thread Concepts
• What are Processor, process, threads?
Thread concepts:
1. Address Space
- Region
Fixed: un-modifiable text region containing program code.
Heap: part of which is initialized by values.
- There are indefinite no. of regions because a separate stack is
needed for each thread.
Fixed
Heap
Stack
3
Isha Padhy, Department of CSE,CBIT,
Hyderabad
2. Creation of new processes
a. Choice of a target host:
Node where process will reside, consists of some policy.
1. Transfer Policy: Whether to situate a new process locally or remotely
depending on load of local node.
2. Location Policy : which node should host a new process.
Location Policy can be
a. Static: optimize overall process throughput policy operate w/o regard to
current state of the system.
- Deterministic: ‘A’ should always transfer process to ‘B’
- Probabilistic: ‘A’ should transfer to any of nodes between ‘B’ to ‘E’
b. Adaptive: Apply methods to make allocation( Ex. Measure load at each
node)
4
Isha Padhy, Department of CSE,CBIT,
Hyderabad
b. Creation of new execution environment:
• Two approaches to define address space of newly
created process:
1. Statically defined- Address space regions are
initialized from an executable file.
2. Defined w.r.t. existing execution envt. Ex. In UNIX
the newly created child process can physically share
parent’s address space. The region is not getting
physically copied but the page frames that make up
the inherited region are shared between 2 address
spaces.(COW technique)
5
Isha Padhy, Department of CSE,CBIT,
Hyderabad
COW(Copy on Write)
a) Before write b) After write
Shared
frame
A's page
table
B's page
table
Process A’s address space Process B’s address space
Kernel
RA RB
RB copied
from RA
6
Isha Padhy, Department of CSE,CBIT,
Hyderabad
Threads in Distribution System:
Multi-threaded Clients
• Requirement: conceal the inter-process message propagation
time. To hide communication latencies we can initiate
communication and proceed with other work. Ex downloading
a web page.
With Waiting single
thread
Without Waiting single
thread
Multi-threading
Every element like
image, text ,icons etc in
a web page requires a
TCP/IP connection. So
waiting time time will be
more if we wait for all
the elements to
download first and use
the web page.
Fetch the HTML page
and subsequently
display it.
Display text while
downloading image.
As soon as main HTML
page is fetched every
element is fetched with
separate threads.
7
Isha Padhy, Department of CSE,CBIT,
Hyderabad
Multi-threaded Servers
- Servers on uni-processor systems can be developed to exploit parallelism
with multithreading.
- Ex. File operations with multithreading, without multi-threading, finite-
state- machine
8
Isha Padhy, Department of CSE,CBIT,
Hyderabad
Architecture of Multi-threaded
Servers
1. Worker- pool architecture: Server creates a
fixed no. of “worker threads” to serve the
requests.
Server
N threads
Input-output
Client
Thread 2 makes
T1
Thread 1
requests to server
generates
results
Requests
Receipt &
queuing
9
Isha Padhy, Department of CSE,CBIT,
Hyderabad
2. Thread- per- request architecture:
3. Thread- per- connection architecture
4. Thread-per-object architecture
a. Thread-per-request b. Thread-per-connection c. Thread-per-object
remote
workers
I/O remote
remote I/O
per-connection threads per-object threads
objects objects
objects
10
Isha Padhy, Department of CSE,CBIT,
Hyderabad
Thread Implementation
Kernel Level Implementation:
- Kernels support multi-threaded processes ex.
Windows.
- These kernel provide thread creation and
management system calls, schedule threads.
- Threads within a process can take advantage
of multiprocessor.
- If a thread gets blocked the whole process is
not blocked.
11
Isha Padhy, Department of CSE,CBIT,
Hyderabad
User- level Implementation
• Thread scheduling module is implemented outside the kernel
so it can be customized for a particular application.
• No system call for switching between threads of same
process.
• The process notifies the kernel when either:
- Virtual Processor(VP) * is idle
- Extra virtual processor is required
* Kernel is running on a computer with one or more virtual
processor( physical processor allotted to virtual machines
with different time slot).
* Kernel allocates one or more VP to the process threads which
are controlled by user level scheduler within each process.
12
Isha Padhy, Department of CSE,CBIT,
Hyderabad
The kernel notifies the process when any of 4 events occur:-
1. Virtual processor allocated: VP allocated to process, this is the
first time slice for it. The scheduler (user level) can load the
SA* with the context of a READY thread.
2. If SA is blocked, kernel uses a fresh SA to notify scheduler. The
corresponding thread is BLOCKED and a READY thread is
allocated to notifying SA.
3. If SA unblocked, kernel informs scheduler to release thread as
READY and either allocates a new VP if available or pre-empts
another SA in same process.
4. If SA pre-empted , scheduler places the pre-empted thread to
READY list and reevaluates the thread allocation.
* SA( Scheduler Activation) - Call from kernel to process to notify
allocation of a VP.
No. of SA= No. of VP assigned to process
13
Isha Padhy, Department of CSE,CBIT,
Hyderabad
Operating system Architecture
• Monolithic kernels
• Micro kernels
• Hybrid Kernels
14
Isha Padhy, Department of CSE,CBIT,
Hyderabad

Operating system support in distributed system

  • 1.
    Operating System Support •The OS must provide: - Encapsulation - Concurrent Processing - Protection • OS components: - Process Manager - Thread Manager - Communication Manager - Memory Manager - Supervisor Communication manager Threadmanager Memorymanager Supervisor Process manager 1 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 2.
    Operating System Layer Applications,services Computer & Platform Middleware OS: kernel, libraries & servers networkhardware OS1 Computer & networkhardware Node 1 Node 2 Processes, threads, communication, ... OS2 Processes, threads, communication, ... 2 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 3.
    Process/Thread Concepts • Whatare Processor, process, threads? Thread concepts: 1. Address Space - Region Fixed: un-modifiable text region containing program code. Heap: part of which is initialized by values. - There are indefinite no. of regions because a separate stack is needed for each thread. Fixed Heap Stack 3 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 4.
    2. Creation ofnew processes a. Choice of a target host: Node where process will reside, consists of some policy. 1. Transfer Policy: Whether to situate a new process locally or remotely depending on load of local node. 2. Location Policy : which node should host a new process. Location Policy can be a. Static: optimize overall process throughput policy operate w/o regard to current state of the system. - Deterministic: ‘A’ should always transfer process to ‘B’ - Probabilistic: ‘A’ should transfer to any of nodes between ‘B’ to ‘E’ b. Adaptive: Apply methods to make allocation( Ex. Measure load at each node) 4 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 5.
    b. Creation ofnew execution environment: • Two approaches to define address space of newly created process: 1. Statically defined- Address space regions are initialized from an executable file. 2. Defined w.r.t. existing execution envt. Ex. In UNIX the newly created child process can physically share parent’s address space. The region is not getting physically copied but the page frames that make up the inherited region are shared between 2 address spaces.(COW technique) 5 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 6.
    COW(Copy on Write) a)Before write b) After write Shared frame A's page table B's page table Process A’s address space Process B’s address space Kernel RA RB RB copied from RA 6 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 7.
    Threads in DistributionSystem: Multi-threaded Clients • Requirement: conceal the inter-process message propagation time. To hide communication latencies we can initiate communication and proceed with other work. Ex downloading a web page. With Waiting single thread Without Waiting single thread Multi-threading Every element like image, text ,icons etc in a web page requires a TCP/IP connection. So waiting time time will be more if we wait for all the elements to download first and use the web page. Fetch the HTML page and subsequently display it. Display text while downloading image. As soon as main HTML page is fetched every element is fetched with separate threads. 7 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 8.
    Multi-threaded Servers - Serverson uni-processor systems can be developed to exploit parallelism with multithreading. - Ex. File operations with multithreading, without multi-threading, finite- state- machine 8 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 9.
    Architecture of Multi-threaded Servers 1.Worker- pool architecture: Server creates a fixed no. of “worker threads” to serve the requests. Server N threads Input-output Client Thread 2 makes T1 Thread 1 requests to server generates results Requests Receipt & queuing 9 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 10.
    2. Thread- per-request architecture: 3. Thread- per- connection architecture 4. Thread-per-object architecture a. Thread-per-request b. Thread-per-connection c. Thread-per-object remote workers I/O remote remote I/O per-connection threads per-object threads objects objects objects 10 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 11.
    Thread Implementation Kernel LevelImplementation: - Kernels support multi-threaded processes ex. Windows. - These kernel provide thread creation and management system calls, schedule threads. - Threads within a process can take advantage of multiprocessor. - If a thread gets blocked the whole process is not blocked. 11 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 12.
    User- level Implementation •Thread scheduling module is implemented outside the kernel so it can be customized for a particular application. • No system call for switching between threads of same process. • The process notifies the kernel when either: - Virtual Processor(VP) * is idle - Extra virtual processor is required * Kernel is running on a computer with one or more virtual processor( physical processor allotted to virtual machines with different time slot). * Kernel allocates one or more VP to the process threads which are controlled by user level scheduler within each process. 12 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 13.
    The kernel notifiesthe process when any of 4 events occur:- 1. Virtual processor allocated: VP allocated to process, this is the first time slice for it. The scheduler (user level) can load the SA* with the context of a READY thread. 2. If SA is blocked, kernel uses a fresh SA to notify scheduler. The corresponding thread is BLOCKED and a READY thread is allocated to notifying SA. 3. If SA unblocked, kernel informs scheduler to release thread as READY and either allocates a new VP if available or pre-empts another SA in same process. 4. If SA pre-empted , scheduler places the pre-empted thread to READY list and reevaluates the thread allocation. * SA( Scheduler Activation) - Call from kernel to process to notify allocation of a VP. No. of SA= No. of VP assigned to process 13 Isha Padhy, Department of CSE,CBIT, Hyderabad
  • 14.
    Operating system Architecture •Monolithic kernels • Micro kernels • Hybrid Kernels 14 Isha Padhy, Department of CSE,CBIT, Hyderabad