Title of Topic: MODULE 2 - Course Title: Distributed Systems Faculty Name: Ms. P. Divya
Title of Topic: MODULE 2 - Course Title: Distributed Systems Faculty Name: Ms. P. Divya
Title of Topic: MODULE 2 - Course Title: Distributed Systems Faculty Name: Ms. P. Divya
Module 1 1
20IT902 Distributed systems
Module 1 2
20IT902 Distributed systems
Problem
Solutions
• Multi-processing
• Multi-threading
• One process + event driven programming
20IT902 Distributed systems
What is a Process?
• Execution context
– Program counter (PC)
Stack
– Stack pointer (SP) SP
– Data registers
• Code
• Data
• Stack
Heap
Static Data
PC
Code
Process
20IT902 Distributed systems
What is a Thread?
• Execution context
– Program counter (PC)
Stack (T1)
– Stack pointer (SP) SP (T1)
– Data registers
Stack (T2)
SP (T2)
Heap
Static Data
PC (T1)
PC (T2) Code
Process
20IT902 Distributed systems
• Threads
– Inter-thread communication cheap: can use process memory and may
not need to context switch
– Not secure: a thread can write the memory used by another thread
20IT902 Distributed systems
Thread Implementation
Multithreaded Servers
Trade-offs
Model Characteristics
Threads Parallelism, blocking system calls
Single-threaded process No parallelism, blocking system calls
Event driven
Parallelism, nonblocking system calls
(Finite state machine)
20IT902 Distributed systems
proc factorial n {
if ($n 1) { return 1; } # fac(1) = 1
expr $n * [ factorial [expr $n – 1] ] # fac(n) = n * fac(n – 1)
}
set number … # tells which factorial to compute
set machine … # identify the target machine