Presentation is loading. Please wait.

Presentation is loading. Please wait.

Prof. Leonardo Mostarda University of Camerino

Similar presentations


Presentation on theme: "Prof. Leonardo Mostarda University of Camerino"— Presentation transcript:

1 Prof. Leonardo Mostarda University of Camerino
Distributed Systems – processes Prof. Leonardo Mostarda University of Camerino Prof. Leonardo Mostarda-- Camerino,

2 Last lecture Decentralised architectures
Structured peer-to-peer architectures Unstructured peer-to-peer architectures Hybrid architectures Superpeer architectures Collaborative Distributed Systems

3 Outline Processes Threads Multithreaded clients Multithreaded servers Virtualisation

4 Learning outcomes Understand threads and processes Critically compare threads and processes Understand the use of threads in distributes systems Understand the role of virtualisation in distributes systems

5 Process A process is a program in execution
Processes are like human beings: they are generated they have a life they optionally generate one or more child processes and eventually they die A small difference Each process has exactly one parent

6 Processes: The Process Model
A) Conceptual model of 4 independent, sequential processes B) Multiprogramming of four programs C) Only one program active at any instant

7 Process States Possible process states
running blocked ready Transitions between states shown

8 Processes Creation of processes incurs in high overhead (concurrency transparency) Independent address space Initialising memory Zeroing a data segment Copying the program into the data segment …… Switching between processes incurs in high overhead Saving CPU context (register values, program counter, open files, stack pointer, …) Swap processes between memory and disk Load a new process ……..

9 The Thread Model (a) Three processes each with one thread
(b) One process with three threads

10 The Thread Model Items shared by all threads in a process
Items private to each thread

11 Threads vs Processes Multithreading leads to performance gain(creation and switching are faster) A multithread system maintains minimum information in order to allow different threads to share the same CPU Switching can take place in the user space Processes require Interprocess Communication (IPC) (pipes, message queues, shared memory) which require kernel intervention Advantages of processes? Thread are not automatically protected against each other (no concurrency transparency) Developing multithreading application requires additional intellectual effort

12 Thread Usage in non-distributed systems
A word processor with three threads The user can still write while the text is saved, and the spell check is performed

13 Threads in Distributed systems
Threads allow blocking system calls without blocking the entire process Multiple connection can take place at the same time We describe multithreaded clients We describe multithreaded servers

14 Multithreaded client Clients hide communication latencies with threads
After a thread initiates the communication a different thread can run For instance Google chrome When the html is fetched various threads are used Display the text and GUI elements Fetch images Fetch data When WEB servers are replicated connections are set up to different replicas

15 Multithreaded server Multithreading simplifies the server code and makes easier to develop server with better performance even on uniprocessor systems For instance in a file server A dispatcher reads the incoming request for a file operation An idle worker thread is selected The worker thread can block until data are fetched from the disk The dispatcher can acquire new works A single thread solution would waste CPU (3-4 cannot run in parallel)

16 Multithreaded server What if threads are not available? How do we implement our file server? Finite state machine The server runs as a big state machine There is a single thread that does not block. It records a request and its state (e.g., waiting from disk) and gets the next message The next message may be a replay from the disk Any important comments? The server will have to make use of no blocking calls to send and receive (better performance but hard to program)

17 The Role of Virtualization in Distributed Systems
Every distributed computer system offers an interface to higher level software (Figure a) Virtualisation modifies the existing interface so as to mimic the behaviour of another system (Figure b) Introduced in 1970s to allow legacy software to run on expensive mainframe Different OSs were ported on the IBM 370 mainframe

18 The use of virtualisation today
Hardware and low-level system change fast while higher level applications are more stable. Virtualisation help by porting a legacy interface to new platforms. System administrators can manage a single platform type. An applications runs on its own virtual machine that in turn runs on the platform. Other example?

19 Architectures of Virtual Machines
In order to understand how virtualisation can be realised we need to understand the different levels at which interfaces are provided: An interface between the hardware and software consisting of machine instructions that can be invoked by any program. An interface between the hardware and software, consisting of machine instructions that can be invoked only by privileged programs, such as an operating system.

20 Architectures of Virtual Machines
Interfaces at different levels An interface consisting of system calls as offered by an operating system. An interface consisting of library calls generally forming what is known as an application programming interface (API). In many cases, the aforementioned system calls are hidden by an API.

21 Architectures of Virtual Machines
First way of implement virtualisation A runtime system can provide an abstract instruction set that can be used by applications The runtime system can be an interpreter or the emulation of an OS

22 Architectures of Virtual Machines
Second way of implement virtualisation A layer completely shields the original hardware This is referred to as Virtual Machine Monitor (VMM) Decoupling between hardware and software

23 Summary Processes Threads Multithreaded client Multithreaded server Virtualisation


Download ppt "Prof. Leonardo Mostarda University of Camerino"

Similar presentations


Ads by Google