CS 471 Operating Systems. Spring 2016 Midterm Exam Time 2 & 1/2 hours. Open Book & Notes

Size: px
Start display at page:

Download "CS 471 Operating Systems. Spring 2016 Midterm Exam Time 2 & 1/2 hours. Open Book & Notes"

Transcription

1 CS 471 Operating Systems Spring 2016 Midterm Exam Time 2 & 1/2 hours Open Book & Notes Name: Unix Login:

2 Question 1 (20 points) A. What is the output of the following program if executed as: % Q1A Q1A.c main () for (i=0; i < 3; i++) if (fork() == 0) printf ("I am %c\n", i+'a'); B. What is the output of the following programs if executed as: % Q1B Q1B.c The code is exactly the same as Q4B.c except that: is deleted.

3 Question 2 (20 points) When a process terminates, the Operating System sends a SIGCHILD signal to the parent process. For the parent to find out which of its children is terminated it uses wait system call which returns the terminated process ID. A. What is the output of the following program if executed as: % Q2A Q2A.c int pid [3]; int ChildPID; main () signal(sigchld, sighandle); for (i=0; i < 3; i++) if ((pid[i]=fork()) == 0) printf ("I am %c\n", i+'a'); sleep(i+1); for (i=0; i < 3; i++) pause(); void sighandle(int sig) printf("\nsigchild\n"); ChildPID = wait(null); for (i=0; i < 3; i++) if (ChildPID == pid[i]) printf("%c Terminated\n", i+'a');

4 B. What is the output of the following program if executed as: % Q2B Q2B.c int pid [3]; int ChildPID; main () int j; for (i=0; i < 3; i++) if ((pid[i]=fork()) == 0) signal(sigusr1, sighandle); printf ("I am %c\n", i+'a'); pause(); for (i=0; i < 3; i++) kill (pid[i], SIGUSR1); ChildPID = wait(null); for (j=0; j < 3; j++) if (ChildPID == pid[j]) printf("%c Terminated\n", j+'a'); void sighandle(int sig) printf("\nsigusr1\n");

5 Question 3 (20 points) A. List 3 UNIX system calls that deals with the following aspects of the operating system: 1. Process Control 2. Files Manipulation 3. Interposes Communications. 4. Signal Control

6 B. Consider the following 3 processes submitted in the order: P1, P2 & P3 with estimated CPU times: 6, 4 and 2. Compute the average waiting time if these 3 processes are scheduled according to: 1. FCFS: 2. SJF: 3. RR with Quantum time = 2:

7 Question 4 (20 points) A. What is the output of the following program if executed as: % Q4A Q4A.c static void * thread_funca(void *ignored_argument) pthread_setcancelstate(pthread_cancel_disable, NULL); printf("a going to sleep 5\n"); sleep(5); printf("a slept 5\n"); pthread_setcancelstate(pthread_cancel_enable, NULL); printf("a going to sleep 10\n"); sleep(10); printf("a going to sleep 10\n"); static void * thread_funcb(void *ignored_argument) printf("b going to sleep 5\n"); sleep(5); printf("b slept 5\n"); printf("b going to sleep 10\n"); sleep(10); printf("b going to sleep 10\n"); main(void) pthread_t thra, thrb; void *resa, *resb; pthread_create(&thra, NULL, &thread_funca, NULL); pthread_cancel(thra); pthread_join(thra, &resa); if (resa == PTHREAD_CANCELED) printf("a thread canceled\n\n"); pthread_create(&thrb, NULL, &thread_funcb, NULL); pthread_cancel(thrb); pthread_join(thrb, &resb); if (resb == PTHREAD_CANCELED) printf("b thread canceled\n");

8 B. What is the output of the following programs if executed as: % Q4B 1 Q4B.c #define SIZE 1024 char *ShrdMem; int segment_id; main(int argc, char *argv[]) segment_id=shmget(ipc_private, SIZE*sizeof(char), S_IRUSR S_IWUSR); ShrdMem = (char *) shmat(segment_id, NULL, 0); sprintf(shrdmem, "%s", argv[1]); if (fork() == 0) calc(); printf("for %s the result = %s\n", argv[1], ShrdMem); calc() int sum; int upper; upper = atoi(shrdmem); for (i = 0; i <= upper; i++) sum += pow(2, i); sprintf (ShrdMem, "%d", sum); C. What is the output of the following programs if executed as: % Q4C 2 Q4C.c The code is exactly the same as Q4B.c except that: is deleted.

9 Question 5 (20 points) A. What is the output of the following programs if executed as: % Q5A 3 Q5A.c #define SIZE 10 char Buffer[SIZE]; int pipefd[2]; main(int argc, char *argv[]) sprintf(buffer, "%s", argv[1]); pipe(pipefd); if (fork() == 0) calc(); write (pipefd[1], Buffer, strlen (Buffer)); read (pipefd[0], Buffer, SIZE); printf("for %s the result = %s\n", argv[1], Buffer); calc() int sum; int upper; read (pipefd[0], Buffer, SIZE); upper = atoi(buffer); for (i = 0; i <= upper; i++) sum += pow(2, i); sprintf (Buffer, "%d", sum); write (pipefd[1], Buffer, strlen (Buffer));

10 B. What is the output of the following programs if executed as: % Q5B 4 Q5B.c #define SIZE 10 char Buffer[SIZE]; int sfd; FILE *sfp; char *FNAME="./shfile"; main(int argc, char *argv[]) sprintf(buffer, "%s", argv[1]); sfd = open (FNAME, O_RDWR O_TRUNC O_CREAT, 0600) ; if (fork() == 0) calc(); write (sfd, Buffer, strlen (Buffer)); lseek(sfd, 0, SEEK_SET); read (sfd, Buffer, SIZE); printf("for %s the result = %s\n", argv[1], Buffer); unlink(fname); calc() int sum; int upper; lseek(sfd, 0, SEEK_SET); read (sfd, Buffer, SIZE); upper = atoi(buffer); for (i = 0; i <= upper; i++) sum += pow(2, i); sprintf (Buffer, "%d", sum); write (sfd, Buffer, strlen (Buffer));

11 C. What is the output of the following programs if executed as: % Q5C 5 Q5C.c #define SIZE 10 char Buffer[SIZE]; int Port; int serverfd, clientfd; main(int argc, char *argv[]) srand(time(null)); Port = rand() % ; sprintf(buffer, "%s", argv[1]); if (fork() == 0) calc(); CreateServerSocket(); write (serverfd, Buffer, strlen (Buffer)); read (serverfd, Buffer, SIZE); printf("for %s the result = %s\n", argv[1], Buffer); calc() int sum; int upper; CreateClientSocket(); read (clientfd, Buffer, SIZE); upper = atoi(buffer); for (i = 0; i <= upper; i++) sum += pow(2, i); sprintf (Buffer, "%d", sum); write (clientfd, Buffer, strlen (Buffer));

12 CreateServerSocket() int len, listenfd; struct sockaddr_in servaddr, cliaddr; listenfd = socket (AF_INET, SOCK_STREAM, 0); bzero (&servaddr, sizeof (servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl (INADDR_ANY); servaddr.sin_port = htons (Port); if (bind (listenfd, (SA *) & servaddr, sizeof (servaddr)) == -1) perror ("...>>>>> bind ERROR <<<<<..."); exit (-1); listen (listenfd, 0); len = sizeof (cliaddr); serverfd = accept (listenfd, (SA *) & cliaddr, &len); CreateClientSocket() struct sockaddr_in servaddr; struct hostent *hp ; clientfd = socket (AF_INET, SOCK_STREAM, 0); bzero (&servaddr, sizeof (servaddr)); hp = gethostbyname ("localhost"); bcopy (hp->h_addr, &(servaddr.sin_addr.s_addr), hp->h_length); servaddr.sin_family = AF_INET; servaddr.sin_port = htons (Port); usleep (100); if (connect (clientfd, (SA *) & servaddr, sizeof (servaddr)) < 0) perror ("connect error"); exit (-1);

Network Programming Worksheet 2. Simple TCP Clients and Servers on *nix with C.

Network Programming Worksheet 2. Simple TCP Clients and Servers on *nix with C. Simple TCP Clients and Servers on *nix with C. Aims. This worksheet introduces a simple client and a simple server to experiment with a daytime service. It shows how telnet can be used to test the server.

More information

CS307 Operating Systems Processes

CS307 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 information

Processes. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State

Processes. 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 information

CS321: Computer Networks Socket Programming

CS321: Computer Networks Socket Programming CS321: Computer Networks Socket Programming Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Socket Programming It shows how the network application programs

More information

Piotr Mielecki Ph. D.

Piotr 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 information

UNIX Network Programming. Overview of Socket API Network Programming Basics

UNIX Network Programming. Overview of Socket API Network Programming Basics UNIX Network Programming Overview of Socket API Network Programming Basics 1 Client-Server Model Client Machine A Network Server Machine B Web browser and server FTP client and server Telnet client and

More information

CS321: Computer Networks Introduction to Application Layer

CS321: Computer Networks Introduction to Application Layer CS321: Computer Networks Introduction to Application Layer Dr. Manas Khatua Assistant Professor Dept. of CSE IIT Jodhpur E-mail: manaskhatua@iitj.ac.in Basic Application layer provides services to the

More information

Inter-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 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 information

ECE 435 Network Engineering Lecture 2

ECE 435 Network Engineering Lecture 2 ECE 435 Network Engineering Lecture 2 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 31 August 2017 Announcements Homework 1 will be posted. Will be on website, will announce

More information

Introduction to Client-Server Model

Introduction 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 information

ECE 435 Network Engineering Lecture 2

ECE 435 Network Engineering Lecture 2 ECE 435 Network Engineering Lecture 2 Vince Weaver http://web.eece.maine.edu/~vweaver vincent.weaver@maine.edu 6 September 2018 Announcements Homework 1 will be posted. Will be on website, will announce

More information

Hyo-bong Son Computer Systems Laboratory Sungkyunkwan University

Hyo-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 information

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Exam 2 Questions (document version 1.0)

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Exam 2 Questions (document version 1.0) CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Exam 2 Questions (document version 1.0) Overview Exam 2 will be in class on Thursday, April 13, 2017 from 10:00-11:45AM (please arrive

More information

CS4514 (C04) HELP Session 1 Introduction to Network Programming (v1.3)

CS4514 (C04) HELP Session 1 Introduction to Network Programming (v1.3) CS4514 (C04) HELP Session 1 Introduction to Network Programming (v1.3) Speaker: Frank Posluszny Outline! Project 1 Overview! Unix Network Programming Client Server Communication with netoracle! Project

More information

Unix Network Programming Chapter 4. Elementary TCP Sockets 광운대학교컴퓨터과학과 정보통신연구실 석사과정안중현

Unix 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 information

Embedded System Design

Embedded System Design Embedded System Design Lecture 9 Jaeyong Chung Robust Systems Laboratory Incheon National University Inter-process Commnucation (IPC) Chung EPC6071 2 Inter-process Commnucation (IPC) A set of methods for

More information

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

Sockets. 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 information

Lecture 24. Thursday, November 19 CS 375 UNIX System Programming - Lecture 24 1

Lecture 24. Thursday, November 19 CS 375 UNIX System Programming - Lecture 24 1 Lecture 24 Log into Linux. Copy directory /home/hwang/cs375/lecture24 Final project posted. Due during finals week. Reminder: No class next Tuesday (11/24) Questions? Thursday, November 19 CS 375 UNIX

More information

York University Lassonde School of Engineering Department of Electrical Engineering and Computer Science

York University Lassonde School of Engineering Department of Electrical Engineering and Computer Science York University Lassonde School of Engineering Department of Electrical Engineering and Computer Science Midterm EECS 3221.03Z Operating Systems Fundamentals Feb 26, 2015 (14:30-16:00) Section: EECS3221Z

More information

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1

Reading 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 information

Sockets. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Sockets. 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 information

Semester 2, Computer Communication 352 Module 4

Semester 2, Computer Communication 352 Module 4 Page 4.1; CRICOS Number: 00301J MODULE 4 References: 1. Stevens, Fenner, Rudoff, UNIX Network Programming, vol. 1, Chapter 5. OBJECTIVE Provide detail description on TCP Client-Server Example. Discuss

More information

Client-server model The course that gives CMU its Zip! Network programming Nov 27, Using ports to identify services.

Client-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 information

CS4514 B08 HELP Session 1

CS4514 B08 HELP Session 1 CS4514 B08 HELP Session 1 Presented by Choong-Soo Lee clee01@cs.wpi.edu CS4514 TCP/IP Socket Programming Outline Project 1 Overview Unix Network Programming TCP Client TCP Server Processing commands How

More information

Lecture 3 Overview! Last Lecture! TCP/UDP and Sockets introduction!

Lecture 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 information

PA #2 Reviews. set_name, get_name, del_name. Questions? Will be modified after PA #4 ~

PA #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 information

The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1. Interprocess Communication (IPC) Work Individually (no groups)

The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1. Interprocess Communication (IPC) Work Individually (no groups) The BSD UNIX Socket Interface (CS 640 Lecture) Assignment 1 Work Individually (no groups) Due Date: in class, Monday, September 19 Robert T Olsen olsen@cswiscedu 7390CS Office Hours: 3-5T, 11-12F - exception

More information

socketservertcl a Tcl extension for using SCM_RIGHTS By Shannon Noe - FlightAware

socketservertcl a Tcl extension for using SCM_RIGHTS By Shannon Noe - FlightAware socketservertcl a Tcl extension for using SCM_RIGHTS By Shannon Noe - FlightAware Presented at the 24th annual Tcl/Tk conference, Houston Texas, October 2017 Abstract: Horizontal scaling is used to distribute

More information

ECE322 Systems Programming Project 2: Networking with Matrix Multiplication in C Grant Kimes 12/16/15

ECE322 Systems Programming Project 2: Networking with Matrix Multiplication in C Grant Kimes 12/16/15 ECE322 Systems Programming Project 2: Networking with Matrix Multiplication in C Grant Kimes 12/16/15 This project take two inputted matrices of a given size to multiply. The client sends the data to a

More information

Lab 0. Yvan Petillot. Networks - Lab 0 1

Lab 0. Yvan Petillot. Networks - Lab 0 1 Lab 0 Yvan Petillot Networks - Lab 0 1 What You Will Do In This Lab. The purpose of this lab is to help you become familiar with the UNIX/LINUX on the lab network. This means being able to do editing,

More information

Experiential Learning Workshop on Basics of Socket Programming

Experiential 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 information

Ken French HELP Session 1 CS4514

Ken French HELP Session 1 CS4514 Ken French HELP Session 1 CS4514 CS4514 We expect that you have had a programming course similar to 2005 before coming into this class. Programs will be done in C or C++ We also expect that you will have

More information

A GENERALIZED FRAMEWORK FOR CATV TRANSMISSION ON FUTURE BISDN

A GENERALIZED FRAMEWORK FOR CATV TRANSMISSION ON FUTURE BISDN A GENERALIZED FRAMEWORK FOR CATV TRANSMISSION ON FUTURE BISDN Geng-Sheng (G.S.) Kuo Department of Information Management, National Central University Chung-Li, Taiwan 32054, R.O.C. TEL: +886 3 4263086

More information

Network Programming November 3, 2008

Network 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 information

How do we Communicate? Introduction to Unix Network Programming. What does Alice do? What does Bob do? Two simplest networking programs

How do we Communicate? Introduction to Unix Network Programming. What does Alice do? What does Bob do? Two simplest networking programs Introduction to Unix Network Programming Reference: Stevens Unix Network Programming How do we Communicate? Send a mail from Alice to Bob Bob Alice in Champaign, Bob in Hollywood Example: US Postal Service

More information

CS Operating system Summer Midterm I -- July 11, 2017 You have 115 min (10:00am-11:55pm). Good Luck!

CS Operating system Summer Midterm I -- July 11, 2017 You have 115 min (10:00am-11:55pm). Good Luck! Name / ID (please PRINT) Seq#: Seat #: CS 3733.001 -- Operating system Summer 2017 -- Midterm I -- July 11, 2017 You have 115 min (10:00am-11:55pm). Good Luck! This is a closed book/note examination. But

More information

Review. Preview. Closing a TCP Connection. Closing a TCP Connection. Port Numbers 11/27/2017. Packet Exchange for TCP Connection

Review. Preview. Closing a TCP Connection. Closing a TCP Connection. Port Numbers 11/27/2017. Packet Exchange for TCP Connection Review Preview Algorithms and Issues in Client Software Design Client Architecture Identifying the Location of a Parsing an Address Argument Looking Up a Domain Name Looking Up a Well-Known Port by Name

More information

Inter-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 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 information

A Socket Example. Haris Andrianakis & Angelos Stavrou George Mason University

A 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 information

Interprocess Communication Mechanisms

Interprocess 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 information

Interprocess Communication Mechanisms

Interprocess 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 information

chat.h #ifndef _CHAT_H #define _CHAT_H #define LBUFFSIZE 128 #define CBUFFSIZE 331

chat.h #ifndef _CHAT_H #define _CHAT_H #define LBUFFSIZE 128 #define CBUFFSIZE 331 chat.h #ifndef _CHAT_H #define _CHAT_H #define LBUFFSIZE 128 #define CBUFFSIZE 331 #define INCRSLOT(V) { \ ++(V) ; \ if ((V) >= CBUFFSIZE) \ (V) = 0 ; \ enum Lstates {UNUSED, MESSAGE ; struct linebuff

More information

Java Basics 5 - Sockets. Manuel Oriol - May 4th, 2006

Java Basics 5 - Sockets. Manuel Oriol - May 4th, 2006 Java Basics 5 - Sockets Manuel Oriol - May 4th, 2006 Connected / Disconnected Modes Connected mode: path chosen and packets arrive all, in correct order (e.g. Phone) Disconnected mode: path not chosen

More information

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science

NETWORK PROGRAMMING. Instructor: Junaid Tariq, Lecturer, Department of Computer Science NETWORK PROGRAMMING CSC- 341 25 Instructor: Junaid Tariq, Lecturer, Department of Computer Science 26 9 Lecture Sockets as means for inter-process communication (IPC) application layer Client Process Socket

More information

System Programming. Sockets: examples

System Programming. Sockets: examples Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Socket based client/server

More information

Application Programming Interfaces

Application Programming Interfaces Application Programming Interfaces Stefan D. Bruda Winter 2018 SYSTEM CALLS Machine 1 Machine 2 Application 1 Application 3 Application 4 Application 5 Application 2 API (system functions) API (system

More information

Concurrent Programming

Concurrent 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 information

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Midterm Exam Questions (document version 1.1)

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Midterm Exam Questions (document version 1.1) CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Midterm Exam Questions (document version 1.1) Overview The midterm exam will be in class on Monday, March 28, 2016 from 10:00-11:45AM

More information

NETWORK AND SYSTEM PROGRAMMING. I/O Multiplexing: select and poll function

NETWORK 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 information

Process Turnaround Time Total Wait Time P 1 12 ms 0 ms P 2 21 ms 12 ms P 3 23 ms 18 ms P 4 20 ms 17 ms

Process Turnaround Time Total Wait Time P 1 12 ms 0 ms P 2 21 ms 12 ms P 3 23 ms 18 ms P 4 20 ms 17 ms Name: SOLUTIONS Score: / 100 CSCI-4210/6140 Operating Systems Midterm Exam Thursday 10/9 1-PAGE (2-SIDED) CRIB SHEET ALLOWED; NO CALCULATOR ANSWER ALL QUESTIONS; USE EXTRA PAPER AS NECESSARY 1. [25 POINTS]

More information

Introduction to Socket Programming

Introduction to Socket Programming UNIT II - ELEMENTARY TCP SOCKETS Introduction to Socket Programming Introduction to Sockets Socket address Structures Byte ordering functions address conversion functions Elementary TCP Sockets socket,

More information

Concurrent Programming is Hard! Concurrent Programming. Reminder: Iterative Echo Server. The human mind tends to be sequential

Concurrent 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 information

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

Carnegie 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 information

Introduction to Socket Programming

Introduction to Socket Programming Introduction to Socket Programming (Advanced Computer Networks) By Priyank Shah NET ID : pss160530 A Simple Question What are Sockets? Sockets are communication points on the same or different computers

More information

First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems

First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems University of California, Berkeley College of Engineering Computer Science Division EECS Fall 2018 Ion Stoica First Midterm Exam Solutions October 1, 2018 CS162 Operating Systems Your Name: SID AND 162

More information

ICT 6544 Distributed Systems Lecture 5

ICT 6544 Distributed Systems Lecture 5 ICT 6544 Distributed Systems Lecture 5 Hossen Asiful Mustafa Message Brokers Figure 4-21. The general organization of a message broker in a message-queuing system. IBM s WebSphere Message-Queuing System

More information

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Processes in Unix, Linux, and Windows Unix pre-empted

More information

CSC209H Lecture 9. Dan Zingaro. March 11, 2015

CSC209H Lecture 9. Dan Zingaro. March 11, 2015 CSC209H Lecture 9 Dan Zingaro March 11, 2015 Socket Programming (Kerrisk Ch 56, 57, 59) Pipes and signals are only useful for processes communicating on the same machine Sockets are a general interprocess

More information

CSC Systems Programming Fall Lecture - XV Network Programming - I. Tevfik Ko!ar. Louisiana State University. November 9 th, 2010

CSC Systems Programming Fall Lecture - XV Network Programming - I. Tevfik Ko!ar. Louisiana State University. November 9 th, 2010 CSC 4304 - Systems Programming Fall 2010 Lecture - XV Network Programming - I Tevfik Ko!ar Louisiana State University November 9 th, 2010 1 Network Programming 2 Sockets A Socket is comprised of: a 32-bit

More information

518 Lecture Notes Week 12

518 Lecture Notes Week 12 518 Lecture Notes Week 12 (November 16, 2014) 1/13 518 Lecture Notes Week 12 1 Topics TCP/IP C programing for sockets 2 TCP/IP The socket call (socket_create.c) int main(int argc, char *argv[]) int socket_desc;

More information

Processes and Threads

Processes and Threads Process Processes and Threads A process is an abstraction that represent an executing program A program in execution An instance of a program running on a computer The entity that can be assigned to and

More information

First Midterm Exam September 28, 2017 CS162 Operating Systems

First Midterm Exam September 28, 2017 CS162 Operating Systems University of California, Berkeley College of Engineering Computer Science Division EECS Fall 2017 Ion Stoica First Midterm Exam September 28, 2017 CS162 Operating Systems Your Name: SID AND 162 Login

More information

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

PLEASE 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 information

Sockets. Dong-kun Shin Embedded Software Laboratory Sungkyunkwan University Embedded Software Lab.

Sockets. 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 Internet Connections (1) 2 Connection Clients and servers communicate by sending streams of bytes over

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 17: Processes, Pipes, and Signals Cristina Nita-Rotaru Lecture 17/ Fall 2013 1 Processes in UNIX UNIX identifies processes via a unique Process ID Each process also knows

More information

CS , Fall 2008 Final Exam

CS , Fall 2008 Final Exam Andrew login ID: Full Name: Recitation Section: CS 15-213, Fall 2008 Final Exam Friday. December 12, 2008 Instructions: Make sure that your exam is not missing any sheets, then write your full name, Andrew

More information

Systems programming and Operating systems, 2005 Tentamen

Systems programming and Operating systems, 2005 Tentamen Namn: Person-nummer: Instructions: Systems programming and Operating systems, 2005 Tentamen 2005-12-14 Make sure that your exam is not missing any sheets, then write your name and person-nummer on the

More information

CS , Fall 2008 Final Exam

CS , Fall 2008 Final Exam Andrew login ID: Full Name: Recitation Section: CS 15-213, Fall 2008 Final Exam Friday. December 12, 2008 Instructions: Make sure that your exam is not missing any sheets, then write your full name, Andrew

More information

Elementary TCP Sockets

Elementary TCP Sockets Elementary TCP Sockets Chapter 4 UNIX Network Programming Vol. 1, Second Ed. Stevens Distributed Computer Systems 1 socket interface Application 1 Application 2 socket interface user kernel user kernel

More information

CS 370 Operating Systems

CS 370 Operating Systems NAME S.ID. # CS 370 Operating Systems Mid-term Example Instructions: The exam time is 50 minutes. CLOSED BOOK. 1. [24 pts] Multiple choice. Check one. a. Multiprogramming is: An executable program that

More information

Concurrent Servers. Overview. In our current assignment we have the following changes:

Concurrent Servers. Overview. In our current assignment we have the following changes: Concurrent Servers Overview In our current assignment we have the following changes: Concurrent server Session command with an argument of the session name Shutdown command 2 Concurrent Server When a client

More information

Chapter 3 Processes we will completely ignore threads today

Chapter 3 Processes we will completely ignore threads today Chapter 3 Processes we will completely ignore threads today Images from Silberschatz Pacific University 1 Process Define: Memory Regions: Loaded from executable file: ELF: Executable and Linkable Format

More information

CSE 421/521 - Operating Systems Fall 2011 Recitations. Recitation - III Networking & Concurrent Programming Prof. Tevfik Kosar. Presented by...

CSE 421/521 - Operating Systems Fall 2011 Recitations. Recitation - III Networking & Concurrent Programming Prof. Tevfik Kosar. Presented by... CSE 421/521 - Operating Systems Fall 2011 Recitations Recitation - III Networking & Concurrent Programming Prof. Tevfik Kosar Presented by... University at Buffalo September..., 2011 1 Network Programming

More information

Threads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits

Threads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits CS307 What is a thread? Threads A thread is a basic unit of CPU utilization contains a thread ID, a program counter, a register set, and a stack shares with other threads belonging to the same process

More information

Applications and Layered Architectures. Chapter 2 Communication Networks Leon-Garcia, Widjaja

Applications and Layered Architectures. Chapter 2 Communication Networks Leon-Garcia, Widjaja Applications and Layered Architectures Chapter 2 Communication Networks Leon-Garcia, Widjaja Network Architecture Architecture: Any design or orderly arrangement perceived by man. The goals of a network:

More information

CMPSC 311- Introduction to Systems Programming Module: Concurrency

CMPSC 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 information

Message passing systems are popular because they support client-server interactions, where: clients send messages to servers requesting a server.

Message passing systems are popular because they support client-server interactions, where: clients send messages to servers requesting a server. Client-Server Model Message passing systems are popular because they support client-server interactions, where: clients send messages to servers requesting a server. servers provide services requested

More information

Concurrent Programming

Concurrent 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 information

CMPSC 311- Introduction to Systems Programming Module: Concurrency

CMPSC 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 information

System Programming. Signals II

System Programming. Signals II Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Suspending a process 2

More information

How to write a Measurement Telnet Server

How to write a Measurement Telnet Server How to write a Measurement Telnet Server A measurement Telnet server allows you to access remote I/Os with a standard Telnet client program. The following samples shows a way to set the LEDs of a DNP/EVA1

More information

How to write a Measurement Telnet Server

How to write a Measurement Telnet Server How to write a Measurement Telnet Server A measurement Telnet server allows you to access remote I/Os with a standard Telnet client program. The following samples shows a way to set the LEDs of a DNP/EVA2

More information

Announcement (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 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 information

CS 3516: Computer Networks

CS 3516: Computer Networks Welcome to CS 3516: Prof. Yanhua Li Time: 9:00am 9:50am M, T, R, and F Location: AK219 Fall 2018 A-term 1 Some slides are originally from the course materials of the textbook Computer Networking: A Top

More information

Lecture #23 Concurrent Programming

Lecture #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 information

A. Basic Function Calls for Network Communications

A. Basic Function Calls for Network Communications IV. Network Programming A. Basic Function Calls for Network Communications 1 B. Settings for Windows Platform (1) Visual C++ 2008 Express Edition (free version) 2 (2) Winsock Header and Libraries Include

More information

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Final Exam Questions (document version 1.1) WITH SELECTED SOLUTIONS

CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Final Exam Questions (document version 1.1) WITH SELECTED SOLUTIONS CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Final Exam Questions (document version 1.1) WITH SELECTED SOLUTIONS Overview The final exam will be on Tuesday, May 17, 2016 from

More information

CSC209H Lecture 10. Dan Zingaro. March 18, 2015

CSC209H 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 information

Computer Systems Laboratory Sungkyunkwan University

Computer 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 information

Prepared by Prof. Hui Jiang Process. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University

Prepared by Prof. Hui Jiang Process. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University EECS3221.3 Operating System Fundamentals No.2 Process Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University How OS manages CPU usage? How CPU is used? Users use CPU to run

More information

Process. Prepared by Prof. Hui Jiang Dept. of EECS, York Univ. 1. Process in Memory (I) PROCESS. Process. How OS manages CPU usage? No.

Process. Prepared by Prof. Hui Jiang Dept. of EECS, York Univ. 1. Process in Memory (I) PROCESS. Process. How OS manages CPU usage? No. EECS3221.3 Operating System Fundamentals No.2 Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University How OS manages CPU usage? How CPU is used? Users use CPU to run programs

More information

UNIX I/O. Computer Systems: A Programmer's Perspective, Randal E. Bryant and David R. O'Hallaron Prentice Hall, 3 rd edition, 2016, Chapter 10

UNIX I/O. Computer Systems: A Programmer's Perspective, Randal E. Bryant and David R. O'Hallaron Prentice Hall, 3 rd edition, 2016, Chapter 10 Reference: Advanced Programming in the UNIX Environment, Third Edition, W. Richard Stevens and Stephen A. Rago, Addison-Wesley Professional Computing Series, 2013. Chapter 3 Computer Systems: A Programmer's

More information

Process Creation in UNIX

Process Creation in UNIX Process Creation in UNIX int fork() create a child process identical to parent Child process has a copy of the address space of the parent process On success: Both parent and child continue execution at

More information

Computer Network Programming

Computer Network Programming Practical Programming Computer Network Programming Marwan Burelle & David Bouchet david.bouchet.epita@gmail.com 1 Quick Overview 1.IP and Protocol Stack 2.TCP Concepts 3.Client / Server Concepts 4.Socket

More information

CS 3305 Intro to Threads. Lecture 6

CS 3305 Intro to Threads. Lecture 6 CS 3305 Intro to Threads Lecture 6 Introduction Multiple applications run concurrently! This means that there are multiple processes running on a computer Introduction Applications often need to perform

More information

Socket Programming 2007/03/28

Socket Programming 2007/03/28 Socket Programming 2007/03/28 Reference W. Richard Stevens, Unix Network Programming 2/e Volume 1,1998 James F. Kurose and Keith W. Ross, "Computer Networks: A Top-Down Approach Featuring the Internet

More information

Operating Systems. Threads and Signals. Amir Ghavam Winter Winter Amir Ghavam

Operating Systems. Threads and Signals. Amir Ghavam Winter Winter Amir Ghavam 95.300 Operating Systems Threads and Signals Amir Ghavam Winter 2002 1 Traditional Process Child processes created from a parent process using fork Drawbacks Fork is expensive: Memory is copied from a

More information

Oral. Total. Dated Sign (2) (5) (3) (2)

Oral. Total. Dated Sign (2) (5) (3) (2) R N Oral Total Dated Sign (2) (5) (3) (2) Assignment Group- A_07 Problem Definition Write a program using TCP socket for wired network for following Say Hello to Each other ( For all students) File transfer

More information

CS Operating Systems Lab 3: UNIX Processes

CS Operating Systems Lab 3: UNIX Processes CS 346 - Operating Systems Lab 3: UNIX Processes Due: February 15 Purpose: In this lab you will become familiar with UNIX processes. In particular you will examine processes with the ps command and terminate

More information

COE518 Lecture Notes Week 2 (Sept. 12, 2011)

COE518 Lecture Notes Week 2 (Sept. 12, 2011) C)E 518 Operating Systems Week 2 September 12, 2011 1/8 COE518 Lecture Notes Week 2 (Sept. 12, 2011) Topics Creating a cloned process with fork() Running a new process with exec...() Textbook sections

More information