SlideShare a Scribd company logo
1 of 19
Server Architecture Models
Operating Systems
Hebrew University
Spring 2004
Fork-exec model
Server Behavior
Drawbacks
1. This multiprocessing architecture is useful if the
handling of the client request takes some time or a
session state has to be kept by the (child) server
2. HTTP, however, is a stateless protocol. No session
information needs to be kept by the server
3. An HTTP server based on that architecture would be
inefficient
– The master server would have to create a process for each
HTTP connection, which would handle this one connection only
and then die
– While the master server creates a process it cannot accept
incoming requests – a bottleneck for the entire server.
Pre-Forking Model –
The leader-followers pattern
The preforking architecture
is based on a pool of tasks
(processes or threads)
which are playing 3 different
roles:
•wait for requests (listener)
•process a request (worker)
•queue in and wait to
become the listener (idle
worker)
•The listener is the leader,
the idle workers are the
followers
Win32/WinNt MPM
• Uses threads (a lot more performant than Win
processes)
– The number of threads is fixed, since idle threads impose almost
no performance issue
• There are two Windows processes in this
multitasking architecture:
– At restart, the master process creates the child process
– The worker process (child server process) contains the threads
which handle the requests,
– while the supervisor process (master process) makes sure that
the worker process works correctly
– For connection distribution to the workers a job queue is used
Win32/WinNt MPM cont.
• The master-child connection is done via
events
– master to child: shutdown, restart
– child to master: need restart, error that requires
shutdown
• Worker process’ threads:
– master thread – starts one or multiple listeners
– listener(s) thread(s) – accept requests and put into
the job queue
– worker threads – read from the queue and handle
requests (by calling some routine)
Win32/WinNt MPM
MPM for Linux/Unix
• Combine a multiprocessing and a
multithreading model:
– a variable number of processes, which include a
fixed number of threads
– pre-forking model on process level and job queue
model on thread level
– each child process incorporates a listener thread
• The master server creates the child
process, which starts a starter thread that
set up all worker threads and a single
listener thread
MPM for Linux/Unix cont.
• Within each child process, the
communication between the listener and all
worker threads is organized with two
queues:
– the job queue
– the idle queue
• Advantages of this approach are that it
combines:
– the stability of multiprocessing
– the high performance of multithreading
MPM for Linux/Unix
Thread Pool
1. Create a number of threads at process startup and
place them into a pool where they sit and wait for work.
• e.g. for multithreading a web server.
2. A thread from the pool is activated on the request, and
it returns to the pool on completion.
3. Benefits of thread pool:
– Faster service
– Limitation on the number of threads, according to the need.
4. Thread-pool-architecture allows dynamic adjustment
pool size.
Thread Pool Model for Ex4
• From the exercise definition:
Build a multithreaded server.
The main thread will handle user input,
second thread will handle load balancing
between computation threads, additional
three threads will be used to compute
prime numbers, and the last thread will
handle all output.
Thread Pool Model for Ex4
user
output thread
Main
thread
computation
thread
balancing
thread
input
computation
thread
computation
thread
thread creation
int pthread_create(pthread_t *thread, pthread_attr_t *attr,
void* (*start_routine)(void*), void *arg);
thread – pointer to the new thread
attr – the new thread attributes, usually NULL (i.e. system
thread that we can do ‘join’ on it = wait to his end).
start_routine – pointer to the function that is the thread
code, the return value of that function is the end value of
the thread
arg – parameter for the start_routine function
mutex locks
int pthread_mutex_lock(pthread_mutex_t *mutex);
– blocks until the mutex is free, and than locks it
int pthread_mutex_trylock(pthread_mutex_t *mutex);
– fails if the mutex is already locked, otherwise – locks it
int pthread_mutex_unlock(pthread_mutex_t *mutex);
– frees (unlocks) the mutex
Event-driven
• The main program creates acceptors.
• Each acceptor creates event-handler for
each event it is interested in, and the
handler registers for this event.
• The main program listens for events.
• When event occurs, the appropriate
acceptor is notified, notify the handler,
which handle the event.
Event-driven cont.
• Advantages:
– services can run independently
– integrating new services is easy
– a programmer can do his own ‘task management’ and
save context switching (context is saved in the data
structure)
• Drawbacks:
– resource management problems if requests arrive
faster than they are processed
– big overhead for system with short-duration services
– harder to implement than other models
References
Apache Modeling Portal
http://apache.hpi.uni-potsdam.de/document/4_3Multitasking_server.html
Efficient Architectures for object-oriented
component based Middleware
http://www.stal.de

More Related Content

What's hot (15)

Multithreading
Multithreading Multithreading
Multithreading
 
Multithreaded processors ppt
Multithreaded processors pptMultithreaded processors ppt
Multithreaded processors ppt
 
Thread
ThreadThread
Thread
 
Os Threads
Os ThreadsOs Threads
Os Threads
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
P-Threads
P-ThreadsP-Threads
P-Threads
 
Thread management
Thread management Thread management
Thread management
 
Lecture 9 -_pthreads-linux_threads
Lecture 9 -_pthreads-linux_threadsLecture 9 -_pthreads-linux_threads
Lecture 9 -_pthreads-linux_threads
 
Threads .ppt
Threads .pptThreads .ppt
Threads .ppt
 
Threads
ThreadsThreads
Threads
 
4 threads
4 threads4 threads
4 threads
 
OS_Ch5
OS_Ch5OS_Ch5
OS_Ch5
 
Multithreading models
Multithreading modelsMultithreading models
Multithreading models
 
Pthread Library
Pthread LibraryPthread Library
Pthread Library
 

Similar to Sa

Multithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdfMultithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdfHarika Pudugosula
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread poolsmaksym220889
 
Threads in java, Multitasking and Multithreading
Threads in java, Multitasking and MultithreadingThreads in java, Multitasking and Multithreading
Threads in java, Multitasking and Multithreadingssusere538f7
 
chapter4-processes nd processors in DS.ppt
chapter4-processes nd processors in DS.pptchapter4-processes nd processors in DS.ppt
chapter4-processes nd processors in DS.pptaakarshsiwani1
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptxbleh23
 
CIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docx
CIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docxCIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docx
CIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docxclarebernice
 
IEC 60870-5 101 Protocol Server Simulator User manual
IEC 60870-5 101 Protocol Server Simulator User manualIEC 60870-5 101 Protocol Server Simulator User manual
IEC 60870-5 101 Protocol Server Simulator User manualFreyrSCADA Embedded Solution
 
Module2 MultiThreads.ppt
Module2 MultiThreads.pptModule2 MultiThreads.ppt
Module2 MultiThreads.pptshreesha16
 
Multithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdfMultithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdfHarika Pudugosula
 
Multithreaded_Programming_in_Python.pdf
Multithreaded_Programming_in_Python.pdfMultithreaded_Programming_in_Python.pdf
Multithreaded_Programming_in_Python.pdfgiridharsripathi
 
OOPS object oriented programming UNIT-4.pptx
OOPS object oriented programming UNIT-4.pptxOOPS object oriented programming UNIT-4.pptx
OOPS object oriented programming UNIT-4.pptxArulmozhivarman8
 

Similar to Sa (20)

Multithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdfMultithreaded Programming Part- II.pdf
Multithreaded Programming Part- II.pdf
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread pools
 
Threads in java, Multitasking and Multithreading
Threads in java, Multitasking and MultithreadingThreads in java, Multitasking and Multithreading
Threads in java, Multitasking and Multithreading
 
Ch04 threads
Ch04 threadsCh04 threads
Ch04 threads
 
chapter4-processes nd processors in DS.ppt
chapter4-processes nd processors in DS.pptchapter4-processes nd processors in DS.ppt
chapter4-processes nd processors in DS.ppt
 
Chapter 6 os
Chapter 6 osChapter 6 os
Chapter 6 os
 
OS Module-2.pptx
OS Module-2.pptxOS Module-2.pptx
OS Module-2.pptx
 
Threads
ThreadsThreads
Threads
 
CIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docx
CIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docxCIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docx
CIS3110 Winter 2016CIS3110 (Operating Systems) Assig.docx
 
Threads
ThreadsThreads
Threads
 
Pthread
PthreadPthread
Pthread
 
Threading.pptx
Threading.pptxThreading.pptx
Threading.pptx
 
Threads
ThreadsThreads
Threads
 
MULTI THREADING.pptx
MULTI THREADING.pptxMULTI THREADING.pptx
MULTI THREADING.pptx
 
IEC 60870-5 101 Protocol Server Simulator User manual
IEC 60870-5 101 Protocol Server Simulator User manualIEC 60870-5 101 Protocol Server Simulator User manual
IEC 60870-5 101 Protocol Server Simulator User manual
 
Module2 MultiThreads.ppt
Module2 MultiThreads.pptModule2 MultiThreads.ppt
Module2 MultiThreads.ppt
 
Multithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdfMultithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdf
 
Multithreaded_Programming_in_Python.pdf
Multithreaded_Programming_in_Python.pdfMultithreaded_Programming_in_Python.pdf
Multithreaded_Programming_in_Python.pdf
 
OOPS object oriented programming UNIT-4.pptx
OOPS object oriented programming UNIT-4.pptxOOPS object oriented programming UNIT-4.pptx
OOPS object oriented programming UNIT-4.pptx
 
Topic 4- processes.pptx
Topic 4- processes.pptxTopic 4- processes.pptx
Topic 4- processes.pptx
 

More from rutu_taware (6)

Sa
SaSa
Sa
 
Sa
SaSa
Sa
 
Sa
SaSa
Sa
 
Sa
SaSa
Sa
 
Sa
SaSa
Sa
 
Sa
SaSa
Sa
 

Recently uploaded

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 

Recently uploaded (20)

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 

Sa

  • 1. Server Architecture Models Operating Systems Hebrew University Spring 2004
  • 4. Drawbacks 1. This multiprocessing architecture is useful if the handling of the client request takes some time or a session state has to be kept by the (child) server 2. HTTP, however, is a stateless protocol. No session information needs to be kept by the server 3. An HTTP server based on that architecture would be inefficient – The master server would have to create a process for each HTTP connection, which would handle this one connection only and then die – While the master server creates a process it cannot accept incoming requests – a bottleneck for the entire server.
  • 5. Pre-Forking Model – The leader-followers pattern The preforking architecture is based on a pool of tasks (processes or threads) which are playing 3 different roles: •wait for requests (listener) •process a request (worker) •queue in and wait to become the listener (idle worker) •The listener is the leader, the idle workers are the followers
  • 6. Win32/WinNt MPM • Uses threads (a lot more performant than Win processes) – The number of threads is fixed, since idle threads impose almost no performance issue • There are two Windows processes in this multitasking architecture: – At restart, the master process creates the child process – The worker process (child server process) contains the threads which handle the requests, – while the supervisor process (master process) makes sure that the worker process works correctly – For connection distribution to the workers a job queue is used
  • 7. Win32/WinNt MPM cont. • The master-child connection is done via events – master to child: shutdown, restart – child to master: need restart, error that requires shutdown • Worker process’ threads: – master thread – starts one or multiple listeners – listener(s) thread(s) – accept requests and put into the job queue – worker threads – read from the queue and handle requests (by calling some routine)
  • 9. MPM for Linux/Unix • Combine a multiprocessing and a multithreading model: – a variable number of processes, which include a fixed number of threads – pre-forking model on process level and job queue model on thread level – each child process incorporates a listener thread • The master server creates the child process, which starts a starter thread that set up all worker threads and a single listener thread
  • 10. MPM for Linux/Unix cont. • Within each child process, the communication between the listener and all worker threads is organized with two queues: – the job queue – the idle queue • Advantages of this approach are that it combines: – the stability of multiprocessing – the high performance of multithreading
  • 12. Thread Pool 1. Create a number of threads at process startup and place them into a pool where they sit and wait for work. • e.g. for multithreading a web server. 2. A thread from the pool is activated on the request, and it returns to the pool on completion. 3. Benefits of thread pool: – Faster service – Limitation on the number of threads, according to the need. 4. Thread-pool-architecture allows dynamic adjustment pool size.
  • 13. Thread Pool Model for Ex4 • From the exercise definition: Build a multithreaded server. The main thread will handle user input, second thread will handle load balancing between computation threads, additional three threads will be used to compute prime numbers, and the last thread will handle all output.
  • 14. Thread Pool Model for Ex4 user output thread Main thread computation thread balancing thread input computation thread computation thread
  • 15. thread creation int pthread_create(pthread_t *thread, pthread_attr_t *attr, void* (*start_routine)(void*), void *arg); thread – pointer to the new thread attr – the new thread attributes, usually NULL (i.e. system thread that we can do ‘join’ on it = wait to his end). start_routine – pointer to the function that is the thread code, the return value of that function is the end value of the thread arg – parameter for the start_routine function
  • 16. mutex locks int pthread_mutex_lock(pthread_mutex_t *mutex); – blocks until the mutex is free, and than locks it int pthread_mutex_trylock(pthread_mutex_t *mutex); – fails if the mutex is already locked, otherwise – locks it int pthread_mutex_unlock(pthread_mutex_t *mutex); – frees (unlocks) the mutex
  • 17. Event-driven • The main program creates acceptors. • Each acceptor creates event-handler for each event it is interested in, and the handler registers for this event. • The main program listens for events. • When event occurs, the appropriate acceptor is notified, notify the handler, which handle the event.
  • 18. Event-driven cont. • Advantages: – services can run independently – integrating new services is easy – a programmer can do his own ‘task management’ and save context switching (context is saved in the data structure) • Drawbacks: – resource management problems if requests arrive faster than they are processed – big overhead for system with short-duration services – harder to implement than other models
  • 19. References Apache Modeling Portal http://apache.hpi.uni-potsdam.de/document/4_3Multitasking_server.html Efficient Architectures for object-oriented component based Middleware http://www.stal.de