CONCURRENT PROGRAMMING. Lecture 5
|
|
- Magnus George
- 6 years ago
- Views:
Transcription
1 CONCURRENT PROGRAMMING Lecture 5
2 Last lecture TCP I/O RIO: buffered I/O. Unix IO Question: difference between send() and write()? MSG_DONTWAIT, MSG_NOSIGNAL 2
3 Concurrent Programming is Hard! The human mind tends to be sequential The notion of time is often misleading Thinking about all possible sequences of events in a computer system is at least error prone and frequen tly impossible 3
4 Concurrent Programming is Hard! Classical problem classes of concurrent programs: Races: outcome depends on arbitrary scheduling decisio ns elsewhere in the system Example: who gets the last seat on the airplane? Deadlock: improper resource allocation prevents forwar d progress Example: traffic gridlock Livelock / Starvation / Fairness: external events and/or s ystem scheduling decisions can prevent sub-task progre ss Example: people always jump in front of you in line 4
5 Iterative Echo Server Client socket Server socket bind open_listenfd open_clientfd connect Connection request listen accept Client / Server Session rio_writen rio_readlineb rio_readlineb rio_writen Await connection request from next client close EOF rio_readlineb close 5
6 Iterative Servers Iterative servers process one request at a time client 1 server client 2 connect write call read ret read accept read write connect write call read close close accept Wait for Client 1 read write ret read 6
7 Where Does Second Client Block? Second client attempts to conne ct to iterative server Client open_clientfd socket connect rio_writen Connection request Call to connect returns Even though connection not yet accepted Server side TCP manager que ues request Feature known as TCP listen backlog Call to rio_writen returns Server side TCP manager buff ers input data Call to rio_readlineb blocks Server hasn t written anything for it to read yet. rio_readlineb 7
8 Fundamental Flaw of Iterative Servers User goes out to lunch connect write call read ret read Client 1 blocks waiting for user to type in data client 1 server client 2 accept read write Server blocks waiting for data from Client 1 connect write call read Client 2 blocks waiting to read from server Solution: use concurrent servers instead Concurrent servers use multiple concurrent flows to serve multip le clients at the same time 8
9 Creating Concurrent Flows Allow server to handle multiple clients simultaneously 1. Processes Kernel automatically interleaves multiple logical flows Each flow has its own private address space 2. Threads Kernel automatically interleaves multiple logical flows Each flow shares the same address space 3. I/O multiplexing with select() Programmer manually interleaves multiple logical flows All flows share the same address space Relies on lower-level system abstractions 9
10 Concurrent Servers: Multiple Processes Spawn separate process for each client client 1 server client 2 call connect ret connect call fgets User goes out to lunch Client 1 blocks waiting for user to type in data child 1 call read fork... call accept ret accept fork call accept ret accept child 2 call read write close call connect ret connect call fgets write call read end read close 10
11 Review: Iterative Echo Server int main(int argc, char **argv) { int listenfd, connfd; int port = atoi(argv[1]); struct sockaddr_in clientaddr; int clientlen = sizeof(clientaddr); } listenfd = Open_listenfd(port); while (1) { connfd = Accept(listenfd, (SA *)&clientaddr, &clientlen); echo(connfd); Close(connfd); } exit(0); Accept a connection request Handle echo requests until client terminates 11
12 Process-Based Concurrent Server int main(int argc, char **argv) { int listenfd, connfd; int port = atoi(argv[1]); struct sockaddr_in clientaddr; int clientlen=sizeof(clientaddr); } Fork separate process for each client Does not allow any communication between different client handlers Signal(SIGCHLD, sigchld_handler); listenfd = Open_listenfd(port); while (1) { connfd = Accept(listenfd, (SA *) &clientaddr, &clientlen); if (Fork() == 0) { Close(listenfd); /* Child closes its listening socket */ echo(connfd); /* Child services client */ Close(connfd); /* Child closes connection with client */ exit(0); /* Child exits */ } Close(connfd); /* Parent closes connected socket (important!) */ } 12
13 Process-Based Concurrent Server (cont) void sigchld_handler(int sig) { while (waitpid(-1, 0, WNOHANG) > 0) ; return; } Reap all zombie children 13
14 Process Execution Model Connection Requests Client 1 data Client 1 Server Process Listening Server Process Client 2 Server Process Client 2 data Each client handled by independent process No shared state between them Both parent & child have copies of listenfd and connfd Parent must close connfd Child must close listenfd 14
15 Concurrent Server: accept Illustrated Client clientfd listenfd(3) Server 1. Server blocks in accept, waiting for connection request on listening descriptor listenfd Client Connection request clientfd listenfd(3) Server 2. Client makes connection request by calling and blocking in connect Client clientfd listenfd(3) Server Child connfd(4) Server 3. Server returns connfd from accept. Forks child to handle client. Client returns from connect. Connection is now established between clientfd and connfd 15
16 Implementation Must-dos With Process-Based Designs Listening server process must reap zombie children to avoid fatal memory leak Listening server process must close its copy of con nfd Kernel keeps reference for each socket/open file After fork, refcnt(connfd) = 2 Connection will not be closed until refcnt(connfd) == 0 16
17 View from Server s TCP Manager Client 1 Client 2 Server srv>./echoserverp cl1>./echoclient greatwhite.ics.cs.cmu.edu srv> connected to ( ), port cl2>./echoclient greatwhite.ics.cs.cmu.edu srv> connected to ( ), port Connection Host Port Host Port Listening cl cl
18 Pros and Cons of Process-Based Designs + Handle multiple connections concurrently + Clean sharing model file tables (yes) global variables (no) + Simple and straightforward Additional overhead for process control Nontrivial to share data between processes Requires IPC (interprocess communication) mechanisms FIFO s (named pipes), System V shared memory and semaphores 18
19 #2) Event-Based Concurrent Servers Using I/O Multiplex ing Use library functions to construct scheduler within sing le process Server maintains set of active connections Array of connfd s Repeat: Determine which connections have pending inputs If listenfd has input, then accept connection Add new connfd to array Service all connfd s with pending inputs 19
20 Adding Concurency: Step One Start with allowing address re-use int sock, opts; sock = socket( ); // getting the current options setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &opts, sizeof(opts)); Then we set the socket to non-blocking // getting current options if (0 > (opts = fcntl(sock, F_GETFL))) printf( Error \n ); // modifying and applying opts = (opts O_NONBLOCK); if (fcntl(sock, F_SETFL, opts)) printf( Error \n ); bind( ); 20
21 Adding Concurrency: Step Two Monitor sockets with select() int select(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timespec *timeout); So what s an fd_set? Bit vector with FD_SETSIZE bits maxfd Max file descriptor + 1 readfs Bit vector of read descriptors to monitor writefds Bit vector of write descriptors to monitor exceptfds Read the manpage, set to NULL timeout How long to wait with no activity before retur ning, NULL for eternity 21
22 How does the code change? if (listen(sockfd, 5) < 0) { // listen for incoming connections printf( Error listening\n ); init_pool(sockfd, &pool); while (1) { pool.ready_set = &pool.read_set; pool.nready = select(pool.maxfd+1, &pool.ready_set, &pool.write_set, NULL, NULL); if (FD_ISSET(sockfd, &pool.ready_set)) { if (0 > (isock = accept(sockfd, ))) printf( Error accepting\n ); add_client(isock, &caddr, &pool); } check_clients(&pool); } // close it up down here 22
23 What was pool? A struct something like this: typedef struct s_pool { int maxfd; // largest descriptor in sets fd_set read_set; // all active read descriptors fd_set write_set; // all active write descriptors fd_set ready_set; // descriptors ready for reading int nready; // return of select() int maxi; /* highwater index into client array */ int clientfd[fd_setsize]; /* set of active descriptors */ rio_t clientrio[fd_setsize]; /* set of active read buffers */ } pool; 23
24 void init_pool(int sockfd, pool * p); { int i; p->maxfd = -1; for (i=0;i<fd_setsize;i++) p->clientfd[i]=-1; p->maxfd = sockfd; FD_ZERO(&p->read_set); FD_SET(listenfd, &p->read_set); } // close it up down here 24
25 void add_client(int connfd, pool *p) { int i; p->nready--; for (i = 0; i < FD_SETSIZE; i++) /* Find an available slot */ if (p->clientfd[i] < 0) { /* Add connected descriptor to the pool */ p->clientfd[i] = connfd; Rio_readinitb(&p->clientrio[i], connfd); /* Add the descriptor to descriptor set */ FD_SET(connfd, &p->read_set); /* Update max descriptor and pool highwater mark */ if (connfd > p->maxfd) p->maxfd = connfd; if (i > p->maxi) p->maxi = i; break; } if (i == FD_SETSIZE) /* Couldn't find an empty slot */ app_error("add_client error: Too many clients"); }// close it up down here 25
26 void check_clients(pool *p) { int i, connfd, n; char buf[maxline]; rio_t rio; for (i = 0; (i <= p->maxi) && (p->nready > 0); i++) { connfd = p->clientfd[i]; rio = p->clientrio[i]; /* If the descriptor is ready, echo a text line from it */ if ((connfd > 0) && (FD_ISSET(connfd, &p->ready_set))) { p->nready--; if ((n = Rio_readlineb(&rio, buf, MAXLINE))!= 0) { byte_cnt += n; //line:conc:echoservers:beginecho printf("server received %d (%d total) bytes on fd %d\n", n, byte_cnt, connfd); Rio_writen(connfd, buf, n); //line:conc:echoservers:endecho } } } } /* EOF detected, remove descriptor from pool */ else { Close(connfd); //line:conc:echoservers:closeconnfd FD_CLR(connfd, &p->read_set); //line:conc:echoservers:beginremove p->clientfd[i] = -1; //line:conc:echoservers:endremove } 26
27 So what about bit vectors? void FD_ZERO(fd_set *fdset); Clears all the bits void FD_SET(int fd, fd_set *fdset); Sets the bit for fd void FD_CLR(int fd, fd_set *fdset); Clears the bit for fd int FD_ISSET(int fd, fd_set *fdset); Checks whether fd s bit is set 27
28 What about checking clients? The code only tests for new incoming connections But we have many more to test! Store all your client file descriptors In pool is a good idea! Several scenarios Clients are sending us data We may have pending data to write in a buffer Keep the while(1) thin Delegate specifics to functions that access the appropriate d ata Keep it orthogonal! 28
29 Back to that lifecycle Client(s) socket() Server socket() bind() listen() connect() Connection Request select() FD_ISSET(sfd) accept() write( ) read() close( ) check_clients() main loop Client / Server Session(s) EOF read() write() read() close() 29
30 I/O Multiplexed Event Processing Active Descriptors listenfd = 3 Pending Inputs listenfd = 3 Read clientfd clientfd Active Inactive Active Never Used
31 Time out? int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); 31
32 Pros and Cons of I/O Multiplexing + One logical control flow. + Can single-step with a debugger. + No process or thread control overhead. Design of choice for high-performance Web servers and search engines. Significantly more complex to code than process- o r thread-based designs. Hard to provide fine-grained concurrency E.g., our example will hang up with partial lines. Cannot take advantage of multi-core Single thread of control 32
Concurrent Programming November 28, 2007
15-213 Concurrent Programming November 28, 2007 Topics Limitations of iterative servers Process-based concurrent servers Event-based concurrent servers Threads-based concurrent servers class25.ppt Concurrent
More informationConcurrent Programming April 21, 2005
15-213 The course that gives CMU its Zip! Concurrent Programming April 21, 2005 Topics Limitations of iterative servers Process-based concurrent servers Event-based concurrent servers Threads-based concurrent
More informationConcurrent Servers Dec 2, 2009"
Concurrent Servers Dec 2, 2009" Administrivia" 2! Iterative Servers" client 1! server! client 2! call connect ret connect call read ret read close call accept" ret accept" write close call accept" ret
More informationThree Basic Mechanisms for Creating Concurrent Flows. Systemprogrammering 2009 Föreläsning 10 Concurrent Servers. Process-Based Concurrent Server
Systemprogrammering 2009 Föreläsning 10 Concurrent Servers Topics! Limitations of iterative servers! Process-based concurrent servers! Event-based concurrent servers! Threads-based concurrent servers Three
More informationConcurrent Programming is Hard! Concurrent Programming. Reminder: Iterative Echo Server. The human mind tends to be sequential
Concurrent Programming is Hard! Concurrent Programming 15 213 / 18 213: Introduction to Computer Systems 23 rd Lecture, April 11, 213 Instructors: Seth Copen Goldstein, Anthony Rowe, and Greg Kesden The
More informationIterative Servers The course that gives CMU its Zip! Iterative servers process one request at a time. Concurrent Servers
15-213 The course that gives CMU its Zip! Concurrent Servers Dec 3, 2002 Topics! Limitations of iterative servers! Process-based concurrent servers! Event-based concurrent servers! Threads-based concurrent
More informationConcurrent Programming
Concurrent Programming CS 485G-006: Systems Programming Lectures 32 33: 18 20 Apr 2016 1 Concurrent Programming is Hard! The human mind tends to be sequential The notion of time is often misleading Thinking
More informationLecture #23 Concurrent Programming
Lecture #23 Concurrent Programming Nov. 20, 2017 18-600 Foundations of Computer Systems 1 Concurrent Programming is Hard! The human mind tends to be sequential The notion of time is often misleading Thinking
More informationConcurrent Programming
Concurrent Programming 15-213: Introduc0on to Computer Systems 22 nd Lecture, Nov. 11, 2010 Instructors: Randy Bryant and Dave O Hallaron 1 Concurrent Programming is Hard! The human mind tends to be sequen9al
More informationCONCURRENCY MODEL. UNIX Programming 2014 Fall by Euiseong Seo
CONCURRENCY MODEL UNIX Programming 2014 Fall by Euiseong Seo Echo Server Revisited int main (int argc, char *argv[]) {... listenfd = socket(af_inet, SOCK_STREAM, 0); bzero((char *)&saddr, sizeof(saddr));
More informationConcurrent Programming
Concurrent Programming 15-213 / 18-213: Introduc2on to Computer Systems 23 rd Lecture, Nov. 14, 2013 Instructors: Randy Bryant, Dave O Hallaron, and Greg Kesden 1 Concurrent Programming is Hard! The human
More informationCarnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition
Carnegie Mellon 1 Concurrent Programming 15-213: Introduction to Computer Systems 23 rd Lecture, Nov. 13, 2018 2 Concurrent Programming is Hard! The human mind tends to be sequential The notion of time
More informationcall connect call read call connect ret connect call fgets Client 2 blocks waiting to complete its connection request until after lunch!
15-213 The course that gives CMU its Zip! Concurrent Servers December 4, 2001 Topics Limitations of iterative servers Process-based concurrent servers Threads-based concurrent servers Event-based concurrent
More informationConcurrent programming
Concurrent programming : Introduc2on to Computer Systems 24th Lecture Sec2ons 12.1-12.3 Instructors: Ian Foster Gordon Kindlmann Slides borrow copiously from materials by Randy Bryant and Dave O Hallaron
More informationConcurrent Programming
Chapter 13 Concurrent Programming As we learned in Chapter 8, logical control flows are concurrent if they overlap in time. This general phenomenon, known as concurrency, shows up at many different levels
More informationConcurrent Programming. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Concurrent Programming Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Echo Server Revisited int main (int argc, char *argv[]) {... listenfd = socket(af_inet,
More information9/13/2007. Motivations for Sockets What s in a Socket? Working g with Sockets Concurrent Network Applications Software Engineering for Project 1
Daniel Spangenberger 15 441 Computer Networks, Fall 2007 Goal of Networking: Communication Share data Pass Messages Say I want to talk to a friend in Singapore How can I do this? What applications and
More informationConcurrent Programming
CHAPTER 12 Concurrent Programming 121 Concurrent Programming with Processes 935 122 Concurrent Programming with I/O Multiplexing 939 123 Concurrent Programming with Threads 947 124 Shared Variables in
More informationAnnouncement (1) Due date for PA3 is changed (~ next week) PA4 will also be started in the next class. Not submitted. Not scored
Announcement (1) Due date for PA3 is changed (~ next week) PA4 will also be started in the next class Not submitted Not scored 1 Concurrent Programming Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Sanghoon
More informationConcurrent Programming
Concurrent Programming Andrew Case Slides adapted from Mohamed Zahran, Jinyang Li, Clark Barre=, Randy Bryant and Dave O Hallaron 1 Concurrent vs. Parallelism Concurrency: At least two tasks are making
More informationConcurrent Programming
Concurrent Programming is Hard! Concurrent Programming Kai Shen The human mind tends to be sequential Thinking about all possible sequences of events in a computer system is at least error prone and frequently
More informationConcurrent Programming
Concurrent Programming is Hard! Concurrent Programming Kai Shen The human mind tends to be sequential Thinking about all possible sequences of events in a computer system is at least error prone and frequently
More informationNetwork Programming September 6, 2005
class03.ppt Network Programming September 6, 2005 Topics 15-441 David Murray Slides based on those of Dave Maltz, Randy Bryant, Geoff Langale, and the 15-213 crew Programmer s view of the Internet Sockets
More informationComputer Systems Laboratory Sungkyunkwan University
Concurrent Programming Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Echo Server Revisited int main (int argc, char *argv[]) {... listenfd = socket(af_inet, SOCK_STREAM, 0); bzero((char
More informationI/O Models. Kartik Gopalan
I/O Models Kartik Gopalan Types of Concurrency True Concurrency (multiple processes or threads) Multi-processor machines Child processes/threads execute in parallel. Multi-process (forking) servers If
More informationNetwork Programming November 3, 2008
15-213 Network Programming November 3, 2008 Topics Programmer s view of the Internet (review) Sockets interface Writing clients and servers class20.ppt A Client-Server Transaction Most network applications
More informationCSC209H Lecture 10. Dan Zingaro. March 18, 2015
CSC209H Lecture 10 Dan Zingaro March 18, 2015 Creating a Client To create a client that can connect to a server, call the following, in order: socket: create a communication endpoint This is the same as
More informationCISC2200 Threads Spring 2015
CISC2200 Threads Spring 2015 Process We learn the concept of process A program in execution A process owns some resources A process executes a program => execution state, PC, We learn that bash creates
More informationΕργαστήριο 9 I/O Multiplexing
Εργαστήριο 9 I/O Multiplexing Στοεργαστήριοθαμελετηθούν: Server High Level View I/O Multiplexing Solutions for Concurrency nonblocking I/O Use alarm and signal handler to interrupt slow system calls. Use
More informationNETWORK AND SYSTEM PROGRAMMING. I/O Multiplexing: select and poll function
NETWORK AND SYSTEM PROGRAMMING LAB 15 I/O Multiplexing: select and poll function 15.1 objectives What is a Concurrent server Use of Select System call Use of Poll System call 15.2 What is concurrent server?
More informationApproaches to Concurrency
PROCESS AND THREADS Approaches to Concurrency Processes Hard to share resources: Easy to avoid unintended sharing High overhead in adding/removing clients Threads Easy to share resources: Perhaps too easy
More informationNetwork Programming / : Introduc2on to Computer Systems 21 st Lecture, April. 4, Instructors: Todd Mowry and Anthony Rowe
Network Programming 15-213 / 18-213: Introduc2on to Computer Systems 21 st Lecture, April. 4, 2012 Instructors: Todd Mowry and Anthony Rowe 1 A Programmer s View of the Internet Hosts are mapped to a set
More informationSockets and Parallel Computing. CS439: Principles of Computer Systems April 11, 2018
Sockets and Parallel Computing CS439: Principles of Computer Systems April 11, 2018 Last Time Introduction to Networks OSI Model (7 layers) Layer 1: hardware Layer 2: Ethernet (frames) SAN, LAN, WAN Layer
More informationConcurrency. Alan L. Cox Some slides adapted from CMU slides
Concurrency Alan L. Cox alc@rice.edu Some slides adapted from CMU 15.213 slides Objectives Be able to apply three techniques for achieving concurrency Process Thread Event-driven Be able to analyze the
More informationAssignment 2 Group 5 Simon Gerber Systems Group Dept. Computer Science ETH Zurich - Switzerland
Assignment 2 Group 5 Simon Gerber Systems Group Dept. Computer Science ETH Zurich - Switzerland t Your task Write a simple file server Client has to be implemented in Java Server has to be implemented
More informationSockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.
1 Sockets Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University http://nyx.skku.ac.kr Echo Client (1) 2 #include #include #include #include
More informationNetwork Programming /18-243: Introduc3on to Computer Systems 22 nd Lecture, 13 April Instructors: Bill Nace and Gregory Kesden
Network Programming 15-213/18-243: Introduc3on to Computer Systems 22 nd Lecture, 13 April 2010 Instructors: Bill Nace and Gregory Kesden (c) 1998-2010. All Rights Reserved. All work contained herein is
More informationCOMP/ELEC 429/556 Introduction to Computer Networks
COMP/ELEC 429/556 Introduction to Computer Networks Creating a Network Application Some slides used with permissions from Edward W. Knightly, T. S. Eugene Ng, Ion Stoica, Hui Zhang 1 How to Programmatically
More informationCS118 Discussion Week 2. Taqi
CS118 Discussion Week 2 Taqi Outline Any Questions for Course Project 1? Socket Programming: Non-blocking mode Lecture Review: Application Layer Much of the other related stuff we will only discuss during
More informationClient-server model The course that gives CMU its Zip! Network programming Nov 27, Using ports to identify services.
15-213 The course that gives CMU its Zip! Network programming Nov 27, 2001 Topics Client- model Sockets interface Echo and Client- model Every network application is based on the - model: Application is
More informationGlobal Employee Location Server
S4516 HELP Session 1 Global Employee Location Server Jeff Zhou jeffz@cs.wpi.edu 3/19/2011 Modified based on S4514 B05 slides Objective: Description To implement a simple concurrent server that has four
More informationECE 650 Systems Programming & Engineering. Spring 2018
ECE 650 Systems Programming & Engineering Spring 2018 Programming with Network Sockets Tyler Bletsch Duke University Slides are adapted from Brian Rogers (Duke) Sockets We ve looked at shared memory vs.
More informationCS118 Discussion 1A, Week 3. Zengwen Yuan Dodd Hall 78, Friday 10:00 11:50 a.m.
CS118 Discussion 1A, Week 3 Zengwen Yuan Dodd Hall 78, Friday 10:00 11:50 a.m. 1 Outline Application Layer Protocol: DNS, CDN, P2P Transport Layer Protocol: UDP, principles of reliable transport protocol
More informationSockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Sockets Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Internet Connections (1) Connection Clients and servers communicate by sending streams of
More informationPA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~
Sockets Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu PA #2 Reviews set_name, get_name, del_name Will
More informationConcurrent Programming
Concurrent Programming Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Jinhong Kim( jinhong.kim@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Echo Server Revisited int
More informationA Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University
A Socket Example & George Mason University Everything is a file descriptor Most socket system calls operate on file descriptors Server - Quick view socket() bind() listen() accept() send(), recv() close()
More informationHyo-bong Son Computer Systems Laboratory Sungkyunkwan University
Sockets Hyo-bong Son (proshb@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Client-Server Model Most network application is based on the client-server model: A server
More informationISA 563: Fundamentals of Systems Programming
ISA 563: Fundamentals of Systems Programming Advanced IO April 9, 2012 Non-blocking IO Data processing can be much faster than data access Waiting for IO to finish can be time consuming, and may not even
More informationTotal Score is updated. The score of PA4 will be changed! Please check it. Will be changed
Announcement Total Score is updated Please check it Will be changed The score of PA4 will be changed! 1 Concurrent Programming Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Sanghoon Han(sanghoon.han@csl.skku.edu)
More informationAny of the descriptors in the set {1, 4} have an exception condition pending
Page 1 of 6 6.3 select Function This function allows the process to instruct the kernel to wait for any one of multiple events to occur and to wake up the process only when one or more of these events
More informationCS4514 HELP Session 3. Concurrent Server (in APP) Using Go-Back-N (in DLL)
CS4514 HELP Session 3 Concurrent Server (in APP) Using Go-Back-N (in DLL) Description! You are supposed to implement a simple concurrent server on top of an emulated network protocol stack (NWL, DLL, PHL).
More informationConcurrent Programming
Concurrent Programming Prof. Jinkyu Jeong( jinkyu@skku.edu) TA Jinhong Kim( jinhong.kim@csl.skku.edu) TA Seokha Shin(seokha.shin@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu
More informationCSE 333 Lecture fork, pthread_create, select
CSE 333 Lecture 22 -- fork, pthread_create, select Steve Gribble Department of Computer Science & Engineering University of Washington Administrivia HW4 out on Monday - you re gonna love it Final exam
More informationLecture 3 Overview! Last Lecture! TCP/UDP and Sockets introduction!
Lecture 3 Overview! Last Lecture! TCP/UDP and Sockets introduction! This Lecture! Elementary TCP sockets! TCP Client-Server example! Source: Stevens book(chapters 4,5), Comer s book (Chapters 20, 21)!
More informationECE 650 Systems Programming & Engineering. Spring 2018
ECE 650 Systems Programming & Engineering Spring 2018 Inter-process Communication (IPC) Tyler Bletsch Duke University Slides are adapted from Brian Rogers (Duke) Recall Process vs. Thread A process is
More informationIntroduction to Client-Server Model
Preview Introduction to Client-Server Model Motivation of Client-Server Model Terminologies and Concepts in Client-Server Model Connectionless vs. Connection-Oriented Stateless vs. Stateful Server Identify
More informationNetwork Programming TDC 561
Network Programming TDC 561 Lecture # 4: Server Design (II) - Concurrent Servers Dr. Ehab S. Al-Shaer School of Computer Science & Telecommunication DePaul University Chicago, IL 1 Unix Signals A signal
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science AUGUST 2012 EXAMINATIONS CSC 209H1Y Instructor: Daniel Zingaro Duration three hours PLEASE HAND IN Examination Aids: one two-sided 8.5x11
More informationInternet protocol stack. Internetworking II: Network programming. April 20, UDP vs TCP. Berkeley Sockets Interface.
15-213 Internetworking II: Network programming Berkeley sockets interface Internet protocol stack April 20, 2000 Topics client/server model Berkeley sockets TCP client and server examples UDP client and
More informationInternetworking II: Network programming. April 20, 2000
15-213 Internetworking II: Network programming Topics April 20, 2000 client/server model Berkeley sockets TCP client and server examples UDP client and server examples I/O multiplexing with select() Internet
More informationGroup-A Assignment No. 6
Group-A Assignment No. 6 R N Oral Total Dated Sign (2) (5) (3) (10) Title : File Transfer using TCP Socket Problem Definition: Use Python for Socket Programming to connect two or more PCs to share a text
More informationCS307 Operating Systems Processes
CS307 Processes Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2018 Process Concept Process a program in execution An operating system executes a variety of
More informationProcesses. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State
CS307 Process Concept Process a program in execution Processes An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks All these activities are
More informationReading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1
Reading Assignment 4 Chapter 4 Threads, due 2/7 1/31/13 CSE325 - Processes 1 What s Next? 1. Process Concept 2. Process Manager Responsibilities 3. Operations on Processes 4. Process Scheduling 5. Cooperating
More informationUnix Network Programming Chapter 4. Elementary TCP Sockets 광운대학교컴퓨터과학과 정보통신연구실 석사과정안중현
Unix Network Programming Chapter 4. Elementary TCP Sockets 광운대학교컴퓨터과학과 정보통신연구실 석사과정안중현 4.1 Introduction A Time line of the typical scenario that takes place between a TCP client and server. Describes the
More informationCSE 43: Computer Networks Structure, Threading, and Blocking. Kevin Webb Swarthmore College September 14, 2017
CSE 43: Computer Networks Structure, Threading, and Blocking Kevin Webb Swarthmore College September 14, 2017 1 Agenda Under-the-hood look at system calls Data buffering and blocking Processes, threads,
More information#include <sys/socket.h> int listen(int socket, int backlog); socket. socket. backlog
connection listener #include int listen(int socket, int backlog); socket socket backlog #include int accept(int socket, struct sockaddr *addr, socklen_t *addr_len); socket
More informationRecitation 14: Proxy Lab Part 2
Recitation 14: Proxy Lab Part 2 Instructor: TA(s) 1 Outline Proxylab Threading Threads and Synchronization PXYDRIVE Demo 2 ProxyLab Checkpoint is worth 1%, due Thursday, Nov. 29 th Final is worth 7%, due
More informationInter-Process Communication. Disclaimer: some slides are adopted from the book authors slides with permission 1
Inter-Process Communication Disclaimer: some slides are adopted from the book authors slides with permission 1 Today Inter-Process Communication (IPC) What is it? What IPC mechanisms are available? 2 Inter-Process
More informationserverbase.txt (1) Server Client1 (3) (2) Client2 Child Process1 Child Process2 Note: each child process keeps a separate copy of the DB.
serverbase.txt Client1 (3) (1) (2) Server Client2 Child Process1 Child Process2 Note: each child process keeps a separate copy of the DB. Client APP Layer Server APP Layer NW Layer NW Layer DLL DLL PHL
More informationCSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files
CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files ... and systems programming C basic syntax functions arrays structs
More informationCSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.
CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files... and systems programming C basic syntax functions arrays structs
More informationPiotr Mielecki Ph. D.
Piotr Mielecki Ph. D. http://mielecki.ristel.pl/ piotr.mielecki@pwr.edu.pl pmielecki@gmail.com Building blocks of client-server applications: Client, Server, Middleware. Simple client-server application:
More informationSystem-Level I/O. Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O
System-Level I/O Topics Unix I/O Robust reading and writing Reading file metadata Sharing files I/O redirection Standard I/O A Typical Hardware System CPU chip register file ALU system bus memory bus bus
More informationExperiential Learning Workshop on Basics of Socket Programming
Experiential Learning Workshop on Basics of Socket June 28, 2018 Dr. Ram P Rustagi Professor, CSE Dept KSIT, Bangalore rprustagi@ksit.edu.in Resources https://rprustagi.com/elnt/experiential- Learning.html
More informationProblem Set: Processes
Lecture Notes on Operating Systems Problem Set: Processes 1. Answer yes/no, and provide a brief explanation. (a) Can two processes be concurrently executing the same program executable? (b) Can two running
More informationCSE 153 Design of Operating Systems Fall 2018
CSE 153 Design of Operating Systems Fall 2018 Lecture 4: Processes (2) Threads Process Creation: Unix In Unix, processes are created using fork() int fork() fork() Creates and initializes a new PCB Creates
More informationCMPSC 311- Introduction to Systems Programming Module: Concurrency
CMPSC 311- Introduction to Systems Programming Module: Concurrency Professor Patrick McDaniel Fall 2013 Sequential Programming Processing a network connection as it arrives and fulfilling the exchange
More informationPart Two - Process Management. Chapter 3: Processes
Part Two - Process Management Chapter 3: Processes Chapter 3: Processes 3.1 Process Concept 3.2 Process Scheduling 3.3 Operations on Processes 3.4 Interprocess Communication 3.5 Examples of IPC Systems
More informationCarnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition
Carnegie Mellon 1 Network Programming: Part I 15-213 / 18-213 / 15-513: Introduction to Computer Systems 21 st Lecture, November 6, 2018 2 A Client-Server Transaction Most network applications are based
More informationInterprocess Communication Mechanisms
Interprocess Communication 1 Interprocess Communication Mechanisms shared storage These mechanisms have already been covered. examples: shared virtual memory shared files processes must agree on a name
More informationInterprocess Communication Mechanisms
Interprocess Communication 1 Interprocess Communication Mechanisms ffl shared storage These mechanisms have already been covered. examples: Λ shared virtual memory Λ shared files processes must agree on
More informationCSC209 Review. Yeah! We made it!
CSC209 Review Yeah! We made it! 1 CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files 2 ... and C programming... C basic syntax functions
More informationSocket Programming TCP UDP
Socket Programming TCP UDP Introduction Computer Network hosts, routers, communication channels Hosts run applications Routers forward information Packets: sequence of bytes contain control information
More informationCMPSC 311- Introduction to Systems Programming Module: Concurrency
CMPSC 311- Introduction to Systems Programming Module: Concurrency Professor Patrick McDaniel Fall 2013 Sequential Programming Processing a network connection as it arrives and fulfilling the exchange
More informationCS 43: Computer Networks. 07: Concurrency and Non-blocking I/O Sep 17, 2018
CS 43: Computer Networks 07: Concurrency and Non-blocking I/O Sep 17, 2018 Reading Quiz Lecture 5 - Slide 2 Today Under-the-hood look at system calls Data buffering and blocking Inter-process communication
More informationProject 1: A Web Server Called Liso
Project 1: A Web Server Called Liso 15-441/641 Computer Networks Kenneth Yang Viswesh Narayanan "What happens when you type google.com into your browser's address box and press enter?"... Establish a TCP
More informationOperating System Structure
Operating System Structure CSCI 4061 Introduction to Operating Systems Applications Instructor: Abhishek Chandra Operating System Hardware 2 Questions Operating System Structure How does the OS manage
More informationCMPSC 311- Introduction to Systems Programming Module: Concurrency
CMPSC 311- Introduction to Systems Programming Module: Concurrency Professor Patrick McDaniel Fall 2016 Sequential Programming Processing a network connection as it arrives and fulfilling the exchange
More informationNetwork Games Part II. Architecture of Network Game
Network Games Part II Doron Nussbaum Network Games Part II COMP 5900 1 Architecture of Network Game Client Server Peer to Peer Player 1 Player 2 Player 1 Player 2 Server Player 5 Player 3 Player 5 Player
More informationConcurrent Server Using Selective Repeat Data Link Layer
S4514 HELP Session 3 oncurrent Server Using Selective Repeat Data Link Layer Mingzhe Li lmz@cs.wpi.edu 12/05/2005 Description Objective: To implement a simple concurrent server and clients having four
More informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science AUGUST 2011 EXAMINATIONS CSC 209H1Y Instructor: Daniel Zingaro Duration three hours PLEASE HAND IN Examination Aids: one two-sided 8.5x11
More informationNetwork Programming: Part I
Network Programming: Part I 15-213: Introduction to Computer Systems 21 st Lecture, Apr. 5, 2018 Instructor: Franz Franchetti, Seth C. Goldstein, and Brian Railing 1 A Client-Server Transaction Most network
More informationAsynchronous Events on Linux
Asynchronous Events on Linux Frederic.Rossi@Ericsson.CA Open System Lab Systems Research June 25, 2002 Ericsson Research Canada Introduction Linux performs well as a general purpose OS but doesn t satisfy
More informationToday: VM wrap-up Select (if time) Course wrap-up Final Evaluations
Today: VM wrap-up Select (if time) Course wrap-up Final Evaluations Program structure int A[1024][1024] ; Each row is stored in one page Ignore code page in this example One frame allocated Program 1 for
More informationFile I/O. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
File I/O Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Unix Files A Unix file is a sequence of m bytes: B 0, B 1,..., B k,..., B m-1 All I/O devices
More informationProblem Set: Processes
Lecture Notes on Operating Systems Problem Set: Processes 1. Answer yes/no, and provide a brief explanation. (a) Can two processes be concurrently executing the same program executable? (b) Can two running
More informationExample Questions for Midterm EE122, Fall 2008 EECS Berkeley
Example Questions for Midterm EE122, Fall 2008 EECS Berkeley Note: The midterm exam will have six problems or more. The five problems below represent around 60-70% of the workload you should expect at
More informationRedesde Computadores(RCOMP)
Redesde Computadores(RCOMP) Theoretical-Practical (TP) Lesson 07 2016/2017 Berkeley sockets API, C and Java. Basic functions/methods for TCP applications. TCP client and server. Asynchronous reception.
More information