Server Architecture Models Operating Systems Hebrew University Spring 2004.

Slides:



Advertisements
Similar presentations
1 Symbian Client Server Architecture. 2 Client, who (a software module) needs service from service provider (another software module) Server, who provide.
Advertisements

Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Categories of I/O Devices
Threads. Readings r Silberschatz et al : Chapter 4.
Threads. What do we have so far The basic unit of CPU utilization is a process. To run a program (a sequence of code), create a process. Processes are.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
Day 10 Threads. Threads and Processes  Process is seen as two entities Unit of resource allocation (process or task) Unit of dispatch or scheduling (thread.
Processes CSCI 444/544 Operating Systems Fall 2008.
Threads 1 CS502 Spring 2006 Threads CS-502 Spring 2006.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Threads? Threads allow us to have multiple tasks active at the same time in one executable –think of a server handling multiple connections Each thread.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 4: Threads Dr. Mohamed Hefeeda.
Threads. Processes and Threads  Two characteristics of “processes” as considered so far: Unit of resource allocation Unit of dispatch  Characteristics.
Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8 th Edition Chapter 4: Threads.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Chapter 4: Threads Adapted to COP4610 by Robert van Engelen.
Programming Network Servers Topic 6, Chapters 21, 22 Network Programming Kansas State University at Salina.
Chapter 4: Threads. 4.2CSCI 380 Operating Systems Chapter 4: Threads Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Silberschatz, Galvin and Gagne ©2011Operating System Concepts Essentials – 8 th Edition Chapter 4: Threads.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Threads A thread (or lightweight process) is a basic unit of CPU.
Today’s topic Other server design alternatives –Preforked servers –Threaded servers –Prethreaded servers.
Introduction to Threads CS240 Programming in C. Introduction to Threads A thread is a path execution By default, a C/C++ program has one thread called.
10/16/ Realizing Concurrency using the thread model B. Ramamurthy.
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
1 Confidential Enterprise Solutions Group Process and Threads.
Today’s topic Pthread Some materials and figures are obtained from the POSIX threads Programming tutorial at
Threads and Thread Control Thread Concepts Pthread Creation and Termination Pthread synchronization Threads and Signals.
CS345 Operating Systems Threads Assignment 3. Process vs. Thread process: an address space with 1 or more threads executing within that address space,
Source: Operating System Concepts by Silberschatz, Galvin and Gagne.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
Pthreads: A shared memory programming model
1 Pthread Programming CIS450 Winter 2003 Professor Jinhua Guo.
Silberschatz, Galvin and Gagne ©2005 Modified by Dimitris Margaritis, Spring 2007 Chapter 4: Threads.
Chapter 4: Threads. 4.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Chapter 4: Threads Overview Multithreading.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Chapter 6 P-Threads. Names The naming convention for a method/function/operation is: – pthread_thing_operation(..) – Where thing is the object used (such.
CSC 360, Instructor: Kui Wu Thread & PThread. CSC 360, Instructor: Kui Wu Agenda 1.What is thread? 2.User vs kernel threads 3.Thread models 4.Thread issues.
Threads. Readings r Silberschatz et al : Chapter 4.
Netprog: Client/Server Issues1 Issues in Client/Server Programming Refs: Chapter 27.
PRINCIPLES OF OPERATING SYSTEMS Tutorial-4: Multi-process and Multi-threaded Programming CPSC 457, Spring 2015 May 28/29, 2015 Department of Computer Science,
Operating System Concepts
Processes Chapter 3. Processes in Distributed Systems Processes and threads –Introduction to threads –Distinction between threads and processes Threads.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Tutorial 4. In this tutorial session we’ll see Threads.
Threads Some of these slides were originally made by Dr. Roger deBry. They include text, figures, and information from this class’s textbook, Operating.
OPERATING SYSTEM CONCEPT AND PRACTISE
Process concept.
Threads vs. Events SEDA – An Event Model 5204 – Operating Systems.
Processes and Threads Processes and their scheduling
Chapter 4: Threads.
Operating System (013022) Dr. H. Iwidat
Chapter 4: Multithreaded Programming
Threads and Cooperation
Distributed Systems - Comp 655
Realizing Concurrency using Posix Threads (pthreads)
Realizing Concurrency using the thread model
Modified by H. Schulzrinne 02/15/10 Chapter 4: Threads.
Half-Sync/Half-Async (HSHA) and Leader/Followers (LF) Patterns
Issues in Client/Server Programming
Threads Chapter 4.
CSE 451 Autumn 2003 Section 3 October 16.
Prof. Leonardo Mostarda University of Camerino
Realizing Concurrency using Posix Threads (pthreads)
Realizing Concurrency using the thread model
Realizing Concurrency using Posix Threads (pthreads)
Chapter 4: Threads.
POSIX Threads(pthreads)
Presentation transcript:

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

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 Efficient Architectures for object-oriented component based Middleware