Part I: Communication and Networking

Size: px
Start display at page:

Download "Part I: Communication and Networking"

Transcription

1 Review what we learned Part I: Communication and Networking Communication and Networking: Week 5-6, Lectures 2-7

2 Lecture 1 OSI vs TCP/IP model OSI model Protocols TCP/IP model Application FTP SMTP HTTP IMAP Presentation SSL/TLS ACSII Application Session Sockets Transport TCP UDP Transport Network IP Internet Data Link Physical Physical Network Interface

3 Lecture 1 Transmission Control Protocol (TCP) Definition: connection-based protocol that provides a reliable flow of data between two computers Connection-oriented protocol: file or message will be delivered unless connections fails. Reliable data transmission using message acknowledgement and retransmission The order in which the data (called segments) is sent and received over the network is critical to the success of these applications Examples include: HTTP, FTP, and Telnet

4 Lecture 1 User Datagram Protocol (UDP) Definition: sends independent packets of data (called datagrams) between computers without guarantees about arrival and sequencing. Transaction-oriented but not connection-based like TCP: don t know if it will be delivered, it could get lost on the way. Suitable for simple query-response protocols Examples: clock server, Domain Name System,... Suitable for very large numbers of clients Examples: Voice over IP, IPTV, online games,...

5 Lecture 1 UDP vs TCP:4 main differences Reliability: TCP has mechanisms to manages message acknowledgement and retransmissions in case of lost parts, but UDP has no such mechanisms. Ordering: TCP segments are sent in a sequence and they are received in the same sequence, but UDP does not ensure the order of datagrams. Connection: TCP is a heavyweight connection requiring three packets to set up a socket connection, and also handles congestion control and reliability. UDB is a lightweight transport layer. Method of transfer: TCP segments are read as a byte stream (no boundaries between segments), while UDP datagrams are sent individually and are checked for integrity only if they arrive.

6 Lecture 1 UDP vs TCP Feature Name UDP TCP Packet header size 8 bytes 2060 bytes Transport-layer packet entity Datagram Segment Connection oriented No Yes Reliable transport No Yes Preserve message boundary Yes No Ordered delivery No Yes Flow control No Yes Congestion control No Yes Explicit Congestion Notification No Yes

7 Lecture 2-5 Sockets A socket consists of Local socket address: Local IP address and service port number Remote socket address: Only for established TCP sockets Protocol: A transport protocol, e.g., TCP or UDP. A socket address is the combination of an IP address (phone number) and service port number (extension). A socket API is an application programming interface (API), usually provided by the operating system.

8 Lecture 2-5 Service ports Computers often communicate and provide more than one type of service or to talk to multiple hosts/computers at a time Ports are used to distinguish these services Each service offered by a computer is identified by a port number Represented as a positive (16-bit) integer value Some ports have been reserved to support common services FTP: 21/TCP HTTP: 80/TCP,UDP User-level process/services use port number value 1024

9 Lecture 2-5 Establish socket connection Server Client Service Port Connection request Server Client Service Port Service Port Connection

10 Lecture 2-5 Establish socket connection Step 1: The server listens to the socket for a client to make a connection request Step 2: the server accepts the connection if everything goes well Step 3: the server gets a new socket bound to a different port Go to Step 1

11 Lecture 6 What is HTTP? Hypertext Transfer Protocol (HTTP): an application layer protocol for distributed, collaborative, hypermedia information systems Works as a request-response protocol in the client-server computing model. Defined as a reliable transport layer protocol, therefore commonly uses TCP. Client Server Request Results Network (TCP/IP)

12 Lecture 6 How HTTP works? Client: A browser, a web crawler (used by a search engine), or other software uses HTTP. Server: a computer hosting a web site with web pages or other contents, or providing functions on behalf of the client. HTTP session: a sequence of network request-response transactions. A client initiates a request by establishing a TCP connection to a particular port on a HTTP server. The HTTP server listening on that port waits for a client s request message. Upon receiving the request, the server sends back: completion status information about the request; and requested content in its message body.

13 Lecture 6 Part II: Communication and Networking Concurrency and Multi-threading: Week 7-9, Lectures 6-18

14 Lecture 1 Multitasking: Cooperative vs Preemptive Cooperative multitasking: processes control the CPU Used in early multitasking operating systems, e.g., Win 3.1 Transferring control explicitly from one process to another (coroutines) according to a cooperative model Runtime support is simpler to implement Programmer has to handle cooperation: bugs in processes may lock the systems Pre-emptive multi-tasking: Kernel schedules CPU to each task Used in modern multitasking operating systems Operating system s kernel manages (schedules) process access to CPU Preemption: an action performed by kernel: it forces a process to abandon its running state even if it could safely execute Used time slicing mechanism: a process is suspend when a specified amount of time has expired

15 Lecture 1 Preemptive Multitasking Process creation ready Selection Preemption running Process termination Synchronisation statement executed by other processes waiting Synchronisation statement executed by the process

16 Lecture 1 Concurrent programming: Two basic units Processes: a program has a self-contained execution environment has a complete, private set of basic run-time resources has its own memory space totally controlled by the operating system Threads: also called lightweight processes, which is a dispatchable unit of work in a process. Both processes and threads provide an execution environment, but creating a new thread requires fewer resources than creating a new process. A process can be divided into multiple independent threads

17 Lecture 1 More about threads Thread has a definite beginning and an end run inside a single process share the same address space, the resources allocated and the environment of that process A process can be a single thread, which is called main thread. A standalone Java application starts with main thread ( main() ) This main thread can start new independent threads.

18 Lecture 1 Difference between threads and processes Single thread process Code Memory segments Other Data resources Multithreaded process Code Data Other resources Register Stack Register Register Register Stack Stack Stack

19 Lecture 1 Difference between threads and processes Processes are typically independent and might consist of multiple threads Processes have separate address spaces for code, data and other resources, whereas threads share the address space of the process that created it Threads are easier to create than processes Multithreading requires careful programming Processes use inter-process communication mechanisms provided by the OS to communicate with other processes, while threads can directly communicate with other threads in the same process

20 Lecture 1 Context switching Context switching: a procedure of multi-threading for the system to switch between threads running on the available CPUs A context is the minimal set of data used by this task that must be saved to allow a task interruption at any point int time Data to be saved include: Registers: one of a small set of data holding places in CPU, which may hold a computer instruction, a storage address, or any kind of data Program counter: known as an instruction address register, which is a small amount of fast memory that holds the address of the instruction to be executed immediately after the current one other necessary operating system specific data

21 Lecture 1 Advantages of multi-threading These are advantages compared with multi-processing Improves the performance of the program by better usage of system resources: Share the same address space, less overhead for operating system Context-switching between threads is normally inexpensive Better usage of CPU time, e.g., while one thread is blocked (e.g., waiting for completion of an I/O operation), another thread can use the CPU time to perform computations Simpler program design: Control and communication between threads is easy and inexpensive. More responsive programs

22 Lecture 1 Disadvantages of multi-threading These are disadvantages/costs compared with single-threading Context switching overhead: even lighter than multi-processing, CPU still needs to save the register, program counter etc. of the current thread, and load the same of the next thread to execute. More complex design: data shared and accessed by multiple threads needs special attention Increased resource consumption: CPU time, memory to keep its local stack, and operating system resources to manage the thread

23 Lecture 1 Thread vs Runnable Essentially two ways of doing the same thing, but Extending (subclassing) the standard Thread class: Pros: the derived class itself is a thread object and it gains full control over the thread life cycle Cons: your task class must be a descendant of Thread because Java only allows single inheritance. Implementing the Runnable interface: Pros 1: easy to use, e.g., simply defines the unit of work that will be executed in a thread. Pros 2: can extend a class other than Thread Cons: lack of full control over the thread life cycle Rule of thumb: Use Runnable since it is more general and flexible.

24 Lecture 1 Two mechanisms of creating threads Thread Extends Implements Thread (class) Override Runnable (interface) run() method

25 Lecture 1 Issues in multithreading Problems will arise when multiple threads access the shared resources: Q: How threads communicate? A: By sharing the same memory space, e.g., access to fields and the objects reference fields refer to. Efficient, but makes two kinds of errors possible: Thread interference Memory consistency errors Critical section: a piece of code that accesses a shared resource

26 Lecture 1 Thread interference Also called race conditions Errors are introduced when multiple threads access and try to change the same resource, e.g., memory (variables, arrays, objects), system (databases) or file Let s take a look a very simple example: adding/subtracting some values from 0. We first define a Class Counter to do adding/subtracting Suppose we want to reference a Counter object from two threads which add 1 and then subtract 1. We expect we should get the outputs of 0 from both threads, but sometimes it is not. Why?

27 Lecture 1 Three atomic operations Atomic operation: an action either happens completely, or it doesn t happen at all. For a simple add() method: Step 1: Load value from counter into a register Step 2: Add some value to the register Step 3: Store the value in the register back to counter

28 Lecture 1 Thread interference Let s take a look an simple example, where two threads try to increase an integer value by 1 The steps when it went wrong: Thread 1 Thread 2 Integer value 0 read value to r1 0 read value to r2 0 increase value in r1 0 increase value in r2 0 write back 1 write back 1 Step 1: Load integer value to a register Step 3: Store the register to integer vaule

29 Lecture 1 Thread interference: danger and solution Please read and execute my code example for thread interference. You might notice most of the time it runs perfectly well This kind of bug is particularly difficult to find and fix One solution: Synchronisation, that is enforcing exclusive access to a shared resource.

30 Lecture 1 Memory consistency errors Memory consistency errors: different threads have inconsistent views of the same data. Example: Suppose we have one int field: int count = 0; counter is shared between two threads A and B Thread A increments counter: Thread B prints out counter: System.out.println(counter); count++; The output might not be predictable, could be 0 or 1. No guarantee that thread A s change to counter will be visible to thread B

31 Lecture 1 Memory consistency errors Memory consistency errors: different threads have inconsistent views of the same data. The causes of these errors are complex: we only need to know how to avoid them Key for avoiding these errors: understanding the happens-before relationship, also denoted as a b: event a should happen before event b, the result must reflect that no matter what order those events are in reality executed. In Java: a guarantee that memory written to by statement A is visible to statement B, that is, that statement A completes its write before statement B starts its read.

32 Lecture 1 Ways of creating happens-before relationships Write code to explicitly implement happens-before relationships, esp. for executing new threads Use Thread.join() Synchronisation

33 Lecture 1 Intrinsic lock Synchronization is built around an internal entity known as the intrinsic lock, or monitor lock In Java, every object has an intrinsic lock associated with it Intrinsic lock does two things: enforcing exclusive access to an object s state; and establishing happens-before relationships How it works: Thread A acquires the object s intrinsic lock before accessing the object s field exclusive access It release the intrinsic lock when finishes accessing No other thread can acquire the same lock before Thread A releases the lock happens-before relationships

34 Lecture 1 Mechanisms behind Java synchronisation: monitor An important concept in concurrent programming and operating system Monitor: a synchronization construct that allows threads: to have mutual exclusion to have the ability to wait for a certain condition to become true to signal other threads that their condition has been met. A monitor can be formally defined as M = (m, c), where m is intrinsic lock object and c a condition variable which is basically a container of threads that are waiting on a certain condition.

35 Lecture 1 Synchronisation in Java Synchronisation tools Volatile Variables Locks Atomic Operations Reentrant Locks Synchronized keyword Synchronized methods Synchronized statements

36 Liveness: deadlock Liveness and Deadlock Liveness property in concurrent programming means something good eventually happens. More specifically, the ability of an application to execute in a timely manner. Liveness problems include deadlock, starvation and livelock Deadlock: a situation threads are blocked forever, waiting for each other: Can be two threads waiting for another to release a lock Can be more than two processes are waiting for resources in a circular chain

37 Liveness: deadlock 4 Necessary conditions for deadlock A deadlock situation will happen if all of the following conditions (called Coffman conditions) hold simultaneously: Mutual exclusion: at least one resource must be held in a non-sharable mode: Only one thread at a time can use the resource If another thread requests that resource, the requesting thread must wait until the resource has been released Hold and wait: Thread holds one resource while waits for another No preemption: Once a thread is holding a resource, then that resource cannot be taken away from that thread until the thread voluntarily releases it. Circular wait: A thread must be waiting for a resource which is being held by another thread, which in turn is waiting for the first thread to release the resource.

38 Liveness: deadlock How to deal with deadlock? Prevention: make one or more conditions invalid No mutually exclusive access to resource: Nonblocking Synchronization (next week) Threads should not hold resources while waiting Allow resources to be taken away from threads No circular wait: lock ordering design, see blow Dynamic avoidance: Lock ordering: make sure all locks are always taken in the same order by any thread Lock timeout: put a timeout on lock attempts Deadlock detection: manually or algorithmically use a data structure, i.e., graph to detect deadlock ()

39 Liveness: deadlock How to avoid deadlock: Deadlock detection Can be done manually or algorithmically Use Resource-Allocation Graph Searches for a cycle in the graph. If there is a cycle, there MIGHT exist a deadlock Resource vertex Thread vertex Resource A Assignment edge Thread 1 Thread 2 Resource B Request edge

40 Thread signalling Thread signalling Threads often have to coordinate (or synchronise) their actions: several threads start at the same time; a thread waits for other threads to finish To coordinate, they need to signal each other Two types of threads signals Synchronous (what we are dealing): Occur as a direct result of thread execution Should be delivered to currently executing thread Asynchronous: Occur due to an event typically unrelated to the current instruction Threading library must determine each signals recipient so that asynchronous signals are delivered properly Each thread might receive a set of synchronous signals but it can mask all signals except those that it wishes to receive

41 Thread signalling Guarded block: using thread signalling The above naive implementation is non-synchronized guarded block Use a blank loop until the condition becomes true wasting the precious CPU time We should use synchronized guarded block: Current thread is suspended to wait for the condition becomes true It releases the acquired lock on that object leaves the processor to be used by other threads We can use Java thread signalling methods to achieve this Steps: Invoke wait inside a loop that tests for the condition being waited for, also release the lock Another thread who acquires the same lock invokes notifyall to informing all threads waiting on that lock that something important has happened.

42 Thread signalling Semaphore What is a Semaphore? Semaphore: a variable or abstract data type that is used for controlling access, by multiple processes or threads, to a common resource in concurrent programming Very simple idea: if the Semaphore value is 0, an attempt to decrement this value will cause the calling thread to wait until some other thread increments it. Invented by the famous Dutch computer scientist Edsger Dijkstra in 1965 In Java, it is called counting semaphore, which maintains a set of permits (Semaphore value). Usage: to restrict the number of threads than can access some resource. to send signals between threads.

43 Thread signalling Semaphore How Semaphore works? Cnt=2 T1 acquire() T2 T3 T4 acquire() acquire() acquire() continue continue continue awaiting... awaiting... release() T2 continue continue continue continue T4 release() T4 T3 continue release() release() T1 T3

44 Producer consumer problem Producer Consumer problem Producer Consumer problem: also known as bounded-buffer problem) Two threads: the producer and the consumer A shared buffer: a fixed-size queue. The produce: generating a piece of data, putting it into the buffer and start again. The consumer: removing the data continuously from the buffer one piece at a time Requirement: the producer won t try to add data into the buffer if it s full and that the consumer won t try to remove data from an empty buffer. Everyday examples everywhere: rotating sushi bar

45 Producer consumer problem Producer Consumer problem: solutions Three situations: The buffer is full: the producer stops producing, i.e., sleep The buffer is empty: the consumer stops removing, i.e., sleep The buffer is neither full or empty: the producer and the consumer continue working or notify the sleeping producer/consumer to resume Synchronisation is required to avoid thread interference problem deadlock Deadlock: both threads are waiting to be awakened by the other. Once you have found a good solution, the problem becomes a design pattern: Producer Consumer Design Pattern

46 Producer consumer problem Producer Consumer design pattern Producer Consumer design pattern: a classic concurrency or threading programming design pattern Use to separate work that needs to be done from the execution of that work. Also useful for decoupling threads that produce and consume data in different rates Example: application accepts data while processing them in the order they were received. Producer: Producing the data, e.g., queueing up the received data in order - fast Consumer: Consuming the data, e.g., processing the data - slow Java Executor framework (will introduce later) implements Producer Consumer design pattern

47 Executors framework Thread pools Thread pool: a managed collection of worker threads that are created and waiting to perform tasks. A thread pool also contains a job queue which holds tasks waiting to get executed. Benefits of thread pools: Improved performance when executing large numbers of tasks: reuses worker threads to reduce per-task invocation overhead. A means of bounding the resources consumed by threads when executing a collection of tasks. No management of the life cycle of threads. You just need to focus on the tasks that you want the threads to perform, instead of creating, managing and coordinating threads. The best tool for creating thread pools in Java is Executors framework interface

48 Executors framework Thread Pool Task 1 Thread 1 Job queue Task 2 Thread 2 Task 3 Thread n Thread pool

49 Executors framework A few important concepts: Callable Runnable: An interface should be implemented by any class whose instances are intended to be executed by a thread. Callable: An interface that can be implemented as a task that returns a result and may throw an exception. Runnable vs Callable: Similarity: both are designed for classes whose instances are potentially executed by another thread. Difference: Runnable does not return a result and cannot throw a exception. Callable = Runnable objects with a return value.

50 Executors framework Part III: Web applications and development Web applications and development: Week 10-11, Lectures 18-20

51 Executors framework Java servlet life cycle Java Servlets are run inside a Servlet compatible Servlet Container, e.g., Apache Tomcat, JBoss, Jetty, etc. A Servlets s life cycle consists of the following steps: Step 1: Load Servlet Class. Step 2: Create Instance of Servlet. Step 3: Call the servlets init() method. Step 4: Call the servlets service() method. Step 5: Call the servlets destroy() method. Note 1: By default, a servlet is not loaded until the first request is received for it. Note 2: When the servlet container unloads the servlet, destroy() method is called and the container finalises the servlet and collect garbage.

52 Executors framework Java servlet life cycle Servlet Container Load class Instantiation Instantiation Instantiation init() service() Response Request destroy() Finalisation and garbage collection

53 Java severlet Session Management What is a session and why use it? HTTP protocol and Web Servers are stateless: for web server every request is a new request, even it is the same request from the same client Web applications sometimes require the client information to process the request accordingly: Example 1: After login with your correct authentication credential, how does the server remember you have logged in? Example 2: When you add an entry to your cart, how does the server know what you have added earlier? We need to make the server remember what the user entered before. Session: a conversation between client and server and it can consists of multiple request and response between them

54 Java severlet Session Management Session ID Session ID: a piece of data that is used in HTTP to identify a session Client store the session ID, while the server associate that ID with other client information such as a user name Steps: Step 1: Client start a session, e.g., requests a page Step 2: Server allocates a random session ID upon the request also store the user information Step 3: Session ID is then communicated back to the client Step 4: If the client sends subsequent requests, it also sends back the same session ID Step 5: The server decide whether the session has expired Step 6: If not expired, the server associates the user information with that session ID and response to the requests

55 Java severlet Session Management How to associate user information with ID Three typical ways of associate user information with ID: Hidden form fields: a unique hidden field in the HTML of which the server can set its value to the session ID and keep track of the session Drawback 1: form with the hidden field must be submitted every time when the request is made from client to server. Drawback 2: Not secure: hacker can get the hidden field value from the HTML source and use it to hack the session. Cookies: a small piece of information that is sent from the server and stored in the client s browser. When client make further request, it adds the cookie to the request header and we can utilize it to keep track of the session URL Rewriting: Appends a session identifier parameter with every request and response to keep track of the session.

56 Java severlet Session Management How to associate user information Client Login Post Username=GWBush Password=1+1=3 Set Cookie: SESSIONID=24D644 2B89D1B65FECF1C 8D9FC2232D0 Server Login successful? 1. Create session ID 2. Return session ID in a cookie 3. Store session ID in a database Session ID Username CreatedTime ExpiredTime LassAccessTime Cookie: SESSIONID=24D644 2B89D1B65FECF1C 8D9FC2232D0 Lookup session ID Session still valid? Database Content for GWBush

57 Java severlet Session Management What is Model-View-Controller (MVC)? MVC: a design pattern for efficiently relating the user interface to underlying data models. Three main components: Model: represents the underlying data structures in a software application and the functions to retrieve, insert, and update the data. Note: No information about the user interface. View: a collection of classes representing the elements in the user interface for the user to see on the screen Controller: classes connecting the model and the view, and is used to communicate between classes in the model and view.

58 Java severlet Session Management What is Model-View-Controller (MVC)? User Request Controller Return results Updates Manipulates View Model

59 Java severlet Session Management Advantages of MVC Better complexity management: Software separate presentation (view) from application logic (model) Consequently, code is cleaner and easier to understand Enable large teams of developers for parallel development Flexibility: Presentation or user interface can be completely revamped without touching the model Reusability: The same model can used for other application with different user interfaces

SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II)

SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II) SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (II) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics

More information

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions

Overview. CMSC 330: Organization of Programming Languages. Concurrency. Multiprocessors. Processes vs. Threads. Computation Abstractions CMSC 330: Organization of Programming Languages Multithreaded Programming Patterns in Java CMSC 330 2 Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to

More information

Threads Questions Important Questions

Threads Questions Important Questions Threads Questions Important Questions https://dzone.com/articles/threads-top-80-interview https://www.journaldev.com/1162/java-multithreading-concurrency-interviewquestions-answers https://www.javatpoint.com/java-multithreading-interview-questions

More information

Lecture 8: September 30

Lecture 8: September 30 CMPSCI 377 Operating Systems Fall 2013 Lecture 8: September 30 Lecturer: Prashant Shenoy Scribe: Armand Halbert 8.1 Semaphores A semaphore is a more generalized form of a lock that can be used to regulate

More information

Performance Throughput Utilization of system resources

Performance Throughput Utilization of system resources Concurrency 1. Why concurrent programming?... 2 2. Evolution... 2 3. Definitions... 3 4. Concurrent languages... 5 5. Problems with concurrency... 6 6. Process Interactions... 7 7. Low-level Concurrency

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Multithreading Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to large compute clusters Can perform multiple

More information

Contribution:javaMultithreading Multithreading Prof. Dr. Ralf Lämmel Universität Koblenz-Landau Software Languages Team

Contribution:javaMultithreading Multithreading Prof. Dr. Ralf Lämmel Universität Koblenz-Landau Software Languages Team http://101companies.org/wiki/ Contribution:javaMultithreading Multithreading Prof. Dr. Ralf Lämmel Universität Koblenz-Landau Software Languages Team Non-101samples available here: https://github.com/101companies/101repo/tree/master/technologies/java_platform/samples/javathreadssamples

More information

Java Threads. COMP 585 Noteset #2 1

Java Threads. COMP 585 Noteset #2 1 Java Threads The topic of threads overlaps the boundary between software development and operation systems. Words like process, task, and thread may mean different things depending on the author and the

More information

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference

More information

Dealing with Issues for Interprocess Communication

Dealing with Issues for Interprocess Communication Dealing with Issues for Interprocess Communication Ref Section 2.3 Tanenbaum 7.1 Overview Processes frequently need to communicate with other processes. In a shell pipe the o/p of one process is passed

More information

CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers

CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers CS 2112 Lecture 20 Synchronization 5 April 2012 Lecturer: Andrew Myers 1 Critical sections and atomicity We have been seeing that sharing mutable objects between different threads is tricky We need some

More information

CMSC 132: Object-Oriented Programming II. Threads in Java

CMSC 132: Object-Oriented Programming II. Threads in Java CMSC 132: Object-Oriented Programming II Threads in Java 1 Problem Multiple tasks for computer Draw & display images on screen Check keyboard & mouse input Send & receive data on network Read & write files

More information

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University CS 571 Operating Systems Midterm Review Angelos Stavrou, George Mason University Class Midterm: Grading 2 Grading Midterm: 25% Theory Part 60% (1h 30m) Programming Part 40% (1h) Theory Part (Closed Books):

More information

Interprocess Communication By: Kaushik Vaghani

Interprocess Communication By: Kaushik Vaghani Interprocess Communication By: Kaushik Vaghani Background Race Condition: A situation where several processes access and manipulate the same data concurrently and the outcome of execution depends on the

More information

Chapter 5 Concurrency: Mutual Exclusion and Synchronization

Chapter 5 Concurrency: Mutual Exclusion and Synchronization Operating Systems: Internals and Design Principles Chapter 5 Concurrency: Mutual Exclusion and Synchronization Seventh Edition By William Stallings Designing correct routines for controlling concurrent

More information

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Operating Systems Lecture 4 - Concurrency and Synchronization Adrien Krähenbühl Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Mutual exclusion Hardware solutions Semaphores IPC: Message passing

More information

Multithreaded Programming Part II. CSE 219 Stony Brook University, Department of Computer Science

Multithreaded Programming Part II. CSE 219 Stony Brook University, Department of Computer Science Multithreaded Programming Part II CSE 219 Stony Brook University, Thread Scheduling In a Java application, main is a thread on its own Once multiple threads are made Runnable the thread scheduler of the

More information

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008. CSC 4103 - Operating Systems Spring 2008 Lecture - XII Midterm Review Tevfik Ko!ar Louisiana State University March 4 th, 2008 1 I/O Structure After I/O starts, control returns to user program only upon

More information

IT 540 Operating Systems ECE519 Advanced Operating Systems

IT 540 Operating Systems ECE519 Advanced Operating Systems IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (5 th Week) (Advanced) Operating Systems 5. Concurrency: Mutual Exclusion and Synchronization 5. Outline Principles

More information

Real-Time Programming

Real-Time Programming Real-Time Programming Week 7: Real-Time Operating Systems Instructors Tony Montiel & Ken Arnold rtp@hte.com 4/1/2003 Co Montiel 1 Objectives o Introduction to RTOS o Event Driven Systems o Synchronization

More information

Recap. Contents. Reenterancy of synchronized. Explicit Locks: ReentrantLock. Reenterancy of synchronise (ctd) Advanced Thread programming.

Recap. Contents. Reenterancy of synchronized. Explicit Locks: ReentrantLock. Reenterancy of synchronise (ctd) Advanced Thread programming. Lecture 07: Advanced Thread programming Software System Components 2 Behzad Bordbar School of Computer Science, University of Birmingham, UK Recap How to deal with race condition in Java Using synchronised

More information

THREADS AND CONCURRENCY

THREADS AND CONCURRENCY THREADS AND CONCURRENCY Lecture 22 CS2110 Spring 2013 Graphs summary 2 Dijkstra: given a vertex v, finds shortest path from v to x for each vertex x in the graph Key idea: maintain a 5-part invariant on

More information

Multitasking / Multithreading system Supports multiple tasks

Multitasking / Multithreading system Supports multiple tasks Tasks and Intertask Communication Introduction Multitasking / Multithreading system Supports multiple tasks As we ve noted Important job in multitasking system Exchanging data between tasks Synchronizing

More information

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5

Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Concurrency, Mutual Exclusion and Synchronization C H A P T E R 5 Multiple Processes OS design is concerned with the management of processes and threads: Multiprogramming Multiprocessing Distributed processing

More information

G Programming Languages Spring 2010 Lecture 13. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 13. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 13 Robert Grimm, New York University 1 Review Last week Exceptions 2 Outline Concurrency Discussion of Final Sources for today s lecture: PLP, 12

More information

Real-Time and Concurrent Programming Lecture 4 (F4): Monitors: synchronized, wait and notify

Real-Time and Concurrent Programming Lecture 4 (F4): Monitors: synchronized, wait and notify http://cs.lth.se/eda040 Real-Time and Concurrent Programming Lecture 4 (F4): Monitors: synchronized, wait and notify Klas Nilsson 2016-09-20 http://cs.lth.se/eda040 F4: Monitors: synchronized, wait and

More information

Module 6: Process Synchronization. Operating System Concepts with Java 8 th Edition

Module 6: Process Synchronization. Operating System Concepts with Java 8 th Edition Module 6: Process Synchronization 6.1 Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores

More information

b) Diverse forms of physical connection - all sorts of wired connections, wireless connections, fiber optics, etc.

b) Diverse forms of physical connection - all sorts of wired connections, wireless connections, fiber optics, etc. Objectives CPS221 Lecture: Layered Network Architecture last revised 6/22/10 1. To discuss the OSI layered architecture model 2. To discuss the specific implementation of this model in TCP/IP Materials:

More information

Need for synchronization: If threads comprise parts of our software systems, then they must communicate.

Need for synchronization: If threads comprise parts of our software systems, then they must communicate. Thread communication and synchronization There are two main aspects to Outline for Lecture 19 multithreaded programming in Java: I. Thread synchronization. thread lifecycle, and thread synchronization.

More information

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019

CS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019 CS 31: Introduction to Computer Systems 22-23: Threads & Synchronization April 16-18, 2019 Making Programs Run Faster We all like how fast computers are In the old days (1980 s - 2005): Algorithm too slow?

More information

PROCESS SYNCHRONIZATION

PROCESS SYNCHRONIZATION PROCESS SYNCHRONIZATION Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization

More information

UNIT:2. Process Management

UNIT:2. Process Management 1 UNIT:2 Process Management SYLLABUS 2.1 Process and Process management i. Process model overview ii. Programmers view of process iii. Process states 2.2 Process and Processor Scheduling i Scheduling Criteria

More information

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable What s An OS? Provides environment for executing programs Process abstraction for multitasking/concurrency scheduling Hardware abstraction layer (device drivers) File systems Communication Do we need an

More information

Concurrency. Chapter 5

Concurrency. Chapter 5 Concurrency 1 Chapter 5 2 Concurrency Is a fundamental concept in operating system design Processes execute interleaved in time on a single processor Creates the illusion of simultaneous execution Benefits

More information

Midterm on next week Tuesday May 4. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9

Midterm on next week Tuesday May 4. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9 CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce

More information

Real Time Operating System: Inter-Process Communication (IPC)

Real Time Operating System: Inter-Process Communication (IPC) ECE3411 Fall 2015 Lecture 6c. Real Time Operating System: Inter-Process Communication (IPC) Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut

More information

Concurrency: a crash course

Concurrency: a crash course Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Concurrency: a crash course Concurrent computing Applications designed as a collection of computational units that may execute

More information

Process Management And Synchronization

Process Management And Synchronization Process Management And Synchronization In a single processor multiprogramming system the processor switches between the various jobs until to finish the execution of all jobs. These jobs will share the

More information

Virtual Machine Design

Virtual Machine Design Virtual Machine Design Lecture 4: Multithreading and Synchronization Antero Taivalsaari September 2003 Session #2026: J2MEPlatform, Connected Limited Device Configuration (CLDC) Lecture Goals Give an overview

More information

Concurrency: Deadlock and Starvation. Chapter 6

Concurrency: Deadlock and Starvation. Chapter 6 Concurrency: Deadlock and Starvation Chapter 6 Deadlock Permanent blocking of a set of processes that either compete for system resources or communicate with each other Involve conflicting needs for resources

More information

Threading and Synchronization. Fahd Albinali

Threading and Synchronization. Fahd Albinali Threading and Synchronization Fahd Albinali Parallelism Parallelism and Pseudoparallelism Why parallelize? Finding parallelism Advantages: better load balancing, better scalability Disadvantages: process/thread

More information

Deadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018

Deadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018 Deadlock and Monitors CS439: Principles of Computer Systems September 24, 2018 Bringing It All Together Processes Abstraction for protection Define address space Threads Share (and communicate) through

More information

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: concurrency

Chair of Software Engineering. Java and C# in depth. Carlo A. Furia, Marco Piccioni, Bertrand Meyer. Java: concurrency Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: concurrency Outline Java threads thread implementation sleep, interrupt, and join threads that return values Thread synchronization

More information

CPS221 Lecture: Layered Network Architecture

CPS221 Lecture: Layered Network Architecture CPS221 Lecture: Layered Network Architecture Objectives last revised 9/8/14 1. To discuss the OSI layered architecture model 2. To discuss the specific implementation of this model in TCP/IP Materials:

More information

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?

What is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem? What is the Race Condition? And what is its solution? Race Condition: Where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular

More information

CS350: Final Exam Review

CS350: Final Exam Review University of Waterloo CS350: Final Exam Review Gwynneth Leece, Andrew Song, Rebecca Putinski Winter, 2010 Intro, Threads & Concurrency What are the three views of an operating system? Describe them. Define

More information

Concurrency - Topics. Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads

Concurrency - Topics. Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads Concurrency - Topics Introduction Introduction to Subprogram-Level Concurrency Semaphores Monitors Message Passing Java Threads 1 Introduction Concurrency can occur at four levels: Machine instruction

More information

JAVA CONCURRENCY FRAMEWORK. Kaushik Kanetkar

JAVA CONCURRENCY FRAMEWORK. Kaushik Kanetkar JAVA CONCURRENCY FRAMEWORK Kaushik Kanetkar Old days One CPU, executing one single program at a time No overlap of work/processes Lots of slack time CPU not completely utilized What is Concurrency Concurrency

More information

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads Chapter 4: Threads Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads Chapter 4: Threads Objectives To introduce the notion of a

More information

Concurrency, Thread. Dongkun Shin, SKKU

Concurrency, Thread. Dongkun Shin, SKKU Concurrency, Thread 1 Thread Classic view a single point of execution within a program a single PC where instructions are being fetched from and executed), Multi-threaded program Has more than one point

More information

THREADS & CONCURRENCY

THREADS & CONCURRENCY 27/04/2018 Sorry for the delay in getting slides for today 2 Another reason for the delay: Yesterday: 63 posts on the course Piazza yesterday. A7: If you received 100 for correctness (perhaps minus a late

More information

Threads and Too Much Milk! CS439: Principles of Computer Systems January 31, 2018

Threads and Too Much Milk! CS439: Principles of Computer Systems January 31, 2018 Threads and Too Much Milk! CS439: Principles of Computer Systems January 31, 2018 Last Time CPU Scheduling discussed the possible policies the scheduler may use to choose the next process (or thread!)

More information

Lesson 6: Process Synchronization

Lesson 6: Process Synchronization Lesson 6: Process Synchronization Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks Semaphores Classic Problems of Synchronization

More information

Threads and Parallelism in Java

Threads and Parallelism in Java Threads and Parallelism in Java Java is one of the few main stream programming languages to explicitly provide for user-programmed parallelism in the form of threads. A Java programmer may organize a program

More information

Internet Technology. 06. Exam 1 Review Paul Krzyzanowski. Rutgers University. Spring 2016

Internet Technology. 06. Exam 1 Review Paul Krzyzanowski. Rutgers University. Spring 2016 Internet Technology 06. Exam 1 Review Paul Krzyzanowski Rutgers University Spring 2016 March 2, 2016 2016 Paul Krzyzanowski 1 Question 1 Defend or contradict this statement: for maximum efficiency, at

More information

Agenda. Threads. Single and Multi-threaded Processes. What is Thread. CSCI 444/544 Operating Systems Fall 2008

Agenda. Threads. Single and Multi-threaded Processes. What is Thread. CSCI 444/544 Operating Systems Fall 2008 Agenda Threads CSCI 444/544 Operating Systems Fall 2008 Thread concept Thread vs process Thread implementation - user-level - kernel-level - hybrid Inter-process (inter-thread) communication What is Thread

More information

Internet Technology 3/2/2016

Internet Technology 3/2/2016 Question 1 Defend or contradict this statement: for maximum efficiency, at the expense of reliability, an application should bypass TCP or UDP and use IP directly for communication. Internet Technology

More information

Models of concurrency & synchronization algorithms

Models of concurrency & synchronization algorithms Models of concurrency & synchronization algorithms Lecture 3 of TDA383/DIT390 (Concurrent Programming) Carlo A. Furia Chalmers University of Technology University of Gothenburg SP3 2016/2017 Today s menu

More information

Module 1. Introduction:

Module 1. Introduction: Module 1 Introduction: Operating system is the most fundamental of all the system programs. It is a layer of software on top of the hardware which constitutes the system and manages all parts of the system.

More information

Midterm Exam. October 20th, Thursday NSC

Midterm Exam. October 20th, Thursday NSC CSE 421/521 - Operating Systems Fall 2011 Lecture - XIV Midterm Review Tevfik Koşar University at Buffalo October 18 th, 2011 1 Midterm Exam October 20th, Thursday 9:30am-10:50am @215 NSC Chapters included

More information

CS457 Transport Protocols. CS 457 Fall 2014

CS457 Transport Protocols. CS 457 Fall 2014 CS457 Transport Protocols CS 457 Fall 2014 Topics Principles underlying transport-layer services Demultiplexing Detecting corruption Reliable delivery Flow control Transport-layer protocols User Datagram

More information

November 13, Networking/Interprocess Communication (25 pts)

November 13, Networking/Interprocess Communication (25 pts) Name: (some people got this wrong) User Id: (many people got this wrong) CMPSCI 377: Operating Systems Exam 2: Synchronization, Deadlock, Interprocess Communication, File Systems, and Memory Management

More information

CS 3723 Operating Systems: Final Review

CS 3723 Operating Systems: Final Review CS 3723 Operating Systems: Final Review Instructor: Dr. Tongping Liu Lecture Outline High-level synchronization structure: Monitor Pthread mutex Conditional variables Barrier Threading Issues 1 2 Monitors

More information

CS 153 Design of Operating Systems Winter 2016

CS 153 Design of Operating Systems Winter 2016 CS 153 Design of Operating Systems Winter 2016 Lecture 7: Synchronization Administrivia Homework 1 Due today by the end of day Hopefully you have started on project 1 by now? Kernel-level threads (preemptable

More information

Chapter 32 Multithreading and Parallel Programming

Chapter 32 Multithreading and Parallel Programming Chapter 32 Multithreading and Parallel Programming 1 Objectives To get an overview of multithreading ( 32.2). To develop task classes by implementing the Runnable interface ( 32.3). To create threads to

More information

Operating Systems (1DT020 & 1TT802)

Operating Systems (1DT020 & 1TT802) Uppsala University Department of Information Technology Name: Perso. no: Operating Systems (1DT020 & 1TT802) 2009-05-27 This is a closed book exam. Calculators are not allowed. Answers should be written

More information

Synchronization. CS 475, Spring 2018 Concurrent & Distributed Systems

Synchronization. CS 475, Spring 2018 Concurrent & Distributed Systems Synchronization CS 475, Spring 2018 Concurrent & Distributed Systems Review: Threads: Memory View code heap data files code heap data files stack stack stack stack m1 m1 a1 b1 m2 m2 a2 b2 m3 m3 a3 m4 m4

More information

Deadlock. Only one process can use the resource at a time but once it s done it can give it back for use by another process.

Deadlock. Only one process can use the resource at a time but once it s done it can give it back for use by another process. Deadlock A set of processes is deadlocked if each process in the set is waiting for an event that can be caused by another process in the set. The events that we are mainly concerned with are resource

More information

Chapter 6: Synchronization. Operating System Concepts 8 th Edition,

Chapter 6: Synchronization. Operating System Concepts 8 th Edition, Chapter 6: Synchronization, Silberschatz, Galvin and Gagne 2009 Outline Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization

More information

The University of Texas at Arlington

The University of Texas at Arlington The University of Texas at Arlington Lecture 10: Threading and Parallel Programming Constraints CSE 5343/4342 Embedded d Systems II Objectives: Lab 3: Windows Threads (win32 threading API) Convert serial

More information

Communication Paradigms

Communication Paradigms Communication Paradigms Nicola Dragoni Embedded Systems Engineering DTU Compute 1. Interprocess Communication Direct Communication: Sockets Indirect Communication: IP Multicast 2. High Level Communication

More information

Operating Systems: Quiz2 December 15, Class: No. Name:

Operating Systems: Quiz2 December 15, Class: No. Name: Operating Systems: Quiz2 December 15, 2006 Class: No. Name: Part I (30%) Multiple Choice Each of the following questions has only one correct answer. Fill the correct one in the blank in front of each

More information

Computation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007

Computation Abstractions. Processes vs. Threads. So, What Is a Thread? CMSC 433 Programming Language Technologies and Paradigms Spring 2007 CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Threads and Synchronization May 8, 2007 Computation Abstractions t1 t1 t4 t2 t1 t2 t5 t3 p1 p2 p3 p4 CPU 1 CPU 2 A computer Processes

More information

Synchronization COMPSCI 386

Synchronization COMPSCI 386 Synchronization COMPSCI 386 Obvious? // push an item onto the stack while (top == SIZE) ; stack[top++] = item; // pop an item off the stack while (top == 0) ; item = stack[top--]; PRODUCER CONSUMER Suppose

More information

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to:

General Objectives: To understand the process management in operating system. Specific Objectives: At the end of the unit you should be able to: F2007/Unit5/1 UNIT 5 OBJECTIVES General Objectives: To understand the process management in operating system Specific Objectives: At the end of the unit you should be able to: define program, process and

More information

Multiple Inheritance. Computer object can be viewed as

Multiple Inheritance. Computer object can be viewed as Multiple Inheritance We have seen that a class may be derived from a given parent class. It is sometimes useful to allow a class to be derived from more than one parent, inheriting members of all parents.

More information

UNIT V CONCURRENT PROGRAMMING

UNIT V CONCURRENT PROGRAMMING UNIT V CONCURRENT PROGRAMMING Multi-Threading: Java provides built-in support for multithreaded programming. A multithreaded program contains two or more parts that can run concurrently. Each part of such

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Threads Synchronization Refers to mechanisms allowing a programmer to control the execution order of some operations across different threads in a concurrent

More information

CS Operating Systems

CS Operating Systems CS 4500 - Operating Systems Module 4: The Producer-Consumer Problem and Solution Methods Stanley Wileman Department of Computer Science University of Nebraska at Omaha Omaha, NE 68182-0500, USA June 3,

More information

CS Operating Systems

CS Operating Systems CS 4500 - Operating Systems Module 4: The Producer-Consumer Problem and Solution Methods Stanley Wileman Department of Computer Science University of Nebraska at Omaha Omaha, NE 68182-0500, USA June 3,

More information

Concurrent Programming

Concurrent Programming Concurrency Concurrent Programming A sequential program has a single thread of control. Its execution is called a process. A concurrent program has multiple threads of control. They may be executed as

More information

UDP, TCP, IP multicast

UDP, TCP, IP multicast UDP, TCP, IP multicast Dan Williams In this lecture UDP (user datagram protocol) Unreliable, packet-based TCP (transmission control protocol) Reliable, connection oriented, stream-based IP multicast Process-to-Process

More information

Interprocess Communication

Interprocess Communication Interprocess Communication Nicola Dragoni Embedded Systems Engineering DTU Informatics 4.2 Characteristics, Sockets, Client-Server Communication: UDP vs TCP 4.4 Group (Multicast) Communication The Characteristics

More information

2 Threads vs. Processes

2 Threads vs. Processes 9 2 Threads vs. Processes A process includes an address space (defining all the code and data pages) a resource container (OS resource and accounting information) a thread of control, which defines where

More information

Concurrency Control. Synchronization. Brief Preview of Scheduling. Motivating Example. Motivating Example (Cont d) Interleaved Schedules

Concurrency Control. Synchronization. Brief Preview of Scheduling. Motivating Example. Motivating Example (Cont d) Interleaved Schedules Brief Preview of Scheduling Concurrency Control Nan Niu (nn@cs.toronto.edu) CSC309 -- Summer 2008 Multiple threads ready to run Some mechanism for switching between them Context switches Some policy for

More information

* What are the different states for a task in an OS?

* What are the different states for a task in an OS? * Kernel, Services, Libraries, Application: define the 4 terms, and their roles. The kernel is a computer program that manages input/output requests from software, and translates them into data processing

More information

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 Lecture 9: Readers-Writers and Language Support for Synchronization 9.1.2 Constraints 1. Readers can access database

More information

Tasks. Task Implementation and management

Tasks. Task Implementation and management Tasks Task Implementation and management Tasks Vocab Absolute time - real world time Relative time - time referenced to some event Interval - any slice of time characterized by start & end times Duration

More information

Introduction to OS Synchronization MOS 2.3

Introduction to OS Synchronization MOS 2.3 Introduction to OS Synchronization MOS 2.3 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Challenge How can we help processes synchronize with each other? E.g., how

More information

Remaining Contemplation Questions

Remaining Contemplation Questions Process Synchronisation Remaining Contemplation Questions 1. The first known correct software solution to the critical-section problem for two processes was developed by Dekker. The two processes, P0 and

More information

4.0.1 CHAPTER INTRODUCTION

4.0.1 CHAPTER INTRODUCTION 4.0.1 CHAPTER INTRODUCTION Data networks and the Internet support the human network by supplying seamless, reliable communication between people - both locally and around the globe. On a single device,

More information

MULTITHREADING AND SYNCHRONIZATION. CS124 Operating Systems Fall , Lecture 10

MULTITHREADING AND SYNCHRONIZATION. CS124 Operating Systems Fall , Lecture 10 MULTITHREADING AND SYNCHRONIZATION CS124 Operating Systems Fall 2017-2018, Lecture 10 2 Critical Sections Race conditions can be avoided by preventing multiple control paths from accessing shared state

More information

Chapter 6: Process Synchronization

Chapter 6: Process Synchronization Chapter 6: Process Synchronization Objectives Introduce Concept of Critical-Section Problem Hardware and Software Solutions of Critical-Section Problem Concept of Atomic Transaction Operating Systems CS

More information

CS 159: Parallel Processing

CS 159: Parallel Processing Outline: Concurrency using Java CS 159: Parallel Processing Spring 2007 Processes vs Threads Thread basics Synchronization Locks Examples Avoiding problems Immutable objects Atomic operations High"level

More information

Reintroduction to Concurrency

Reintroduction to Concurrency Reintroduction to Concurrency The execution of a concurrent program consists of multiple processes active at the same time. 9/25/14 7 Dining philosophers problem Each philosopher spends some time thinking

More information

Synchronization in Concurrent Programming. Amit Gupta

Synchronization in Concurrent Programming. Amit Gupta Synchronization in Concurrent Programming Amit Gupta Announcements Project 1 grades are out on blackboard. Detailed Grade sheets to be distributed after class. Project 2 grades should be out by next Thursday.

More information

Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multit

Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multit Threads Multitasking Multitasking allows several activities to occur concurrently on the computer. A distinction is usually made between: Process-based multitasking Thread-based multitasking Multitasking

More information

CS11 Java. Fall Lecture 7

CS11 Java. Fall Lecture 7 CS11 Java Fall 2006-2007 Lecture 7 Today s Topics All about Java Threads Some Lab 7 tips Java Threading Recap A program can use multiple threads to do several things at once A thread can have local (non-shared)

More information

연세대학교전기전자공학과프로세서연구실박사과정김재억.

연세대학교전기전자공학과프로세서연구실박사과정김재억. 이강좌는연세대학교이용석교수연구실에서제작되었으며 copyright가없으므로비영리적인목적에한하여누구든지복사, 배포가가능합니다. 연구실홈페이지에는 고성능마이크로프로세서에관련된많은강의가있으며누구나무료로다운로드받을 수있습니다. 연세대학교전기전자공학과프로세서연구실박사과정김재억 Email: yonglee@yonsei.ac.kr 멀티스레드프로그래밍 (Multithreaded

More information

Different Layers Lecture 21

Different Layers Lecture 21 Different Layers Lecture 21 10/17/2003 Jian Ren 1 The Transport Layer 10/17/2003 Jian Ren 2 Transport Services and Protocols Provide logical communication between app processes running on different hosts

More information