UNIVERSITY OF TORONTO SCARBOROUGH Computer and Mathematical Sciences. APRIL 2016 EXAMINATIONS CSCB09H3S Software Tools & Systems Programming
|
|
- Anna Barton
- 5 years ago
- Views:
Transcription
1 UNIVERSITY OF TORONTO SCARBOROUGH Computer and Mathematical Sciences APRIL 2016 EXAMINATIONS CSCB09H3S Software Tools & Systems Programming Instructor: Bianca Schroeder and Naureen Nizam Duration: 3 hours Examination Aids Allowed: NONE Student Number: Last (Family) Name(s): First (Given) Name(s): Lecture Section: Do NOT turn this page until you have received the signal to start. (In the meantime, please fill out the identification section above, and read the instructions below carefully.) This final examination consists of 9 questions on 21 pages (including this one). A mark of 32 out of 80 is required to pass this course. When you receive the signal to start, please make sure that your copy of the examination is complete. You are not required to add any #include lines, and unless otherwise specified, you may assume a reasonable maximum for characters arrays or other structures. For shell programs, you do not need to include the #!/bin/sh. Note, that on the last 3 pages of the exam we have provided some information for your reference. Good Luck! MARKING GUIDE #1 / 8 #2 / 18 #3 / 8 #4 / 5 #5 / 8 #6 / 10 #7 / 8 #8 / 4 #9 / 11 TOTAL / 80
2 Question 1 [8 marks] For each of the following statements, mark whether it is true or false. No explanation for your answer is necessary. Part (a) [1 mark] The select system call can be used to simultaneously wait on file descriptors that are read-only and file descriptors that are write-only. o TRUE o FALSE Part (b) [1 mark] Signals are used to send several bytes of data from one process to another. o TRUE o FALSE Part (c) [1 mark] A process whose parent process is stuck in an infinite loop is an orphaned process. o TRUE o FALSE Part (d) [1 mark] If I don t have execute permissions on a directory then I cannot see the contents of the directory. o TRUE o FALSE Part (e) [1 mark] A new process is created only when a running process calls fork(). o TRUE o FALSE Part (f) [1 mark] Blocking a signal means that a signal is thrown away and can never be received. o TRUE o FALSE Part (g) [1 mark] If a pointer is written through a pipe to a child process, it can be used to access memory in the parent process. o TRUE o FALSE Part (h) [1 mark] It is important to free memory that you allocate using malloc before you exit the program because otherwise that memory will no longer be available for other programs to use. o TRUE o FALSE Page 2 of 21
3 Question 2 [18 marks] Part (a) [2 marks] What is the system call that allows a user program to map a domain name to the server s corresponding IP address and what underlying internet protocol/service is it based on? Part (b) [2 marks] Write a one-line shell command that will concatenate all the files in the current working directory that ends in.h and put them into a file called headers Part (c) [2 marks] Explain what a zombie state of the process is used for. Part (d) [2 marks] Name two problems that could arise if TCP did not add sequence numbers and checksums to each TCP packet? Page 3 of 21
4 Part (e) [2 marks] Provide one possible reason for why the write system call to a pipe might block and one possible reason for why the read system call to a pipe might block. Part (f) [2 marks] Write two different system calls that a C program could call that would cause the calling process to terminate. If there are arguments to the system call that are required to make a process terminate, state what the values of the arguments must be. Part (g) [4 marks] Assume the contents of the current working directory are: f1 f2 f3 x y z where f1 is an executable program that prints to standard output all command line arguments. Assume that the following shell commands are executed without any errors and that you have permissions to read and execute any of the directory contents. What is printed for each of the following shell commands? (Please note: ` is a back quote and is a single quote). a= f* b=`$a` c= $b echo $a echo $b echo $c echo $? Page 4 of 21
5 Part (h) [1 mark] Explain when and how a user s PATH variable is used? Part (i) [1 mark] Provide the full shell command you would have to type to add /user/bin to a user's PATH variable. Page 5 of 21
6 Question 3 [8 marks] Part (a) [1 mark] Fill in the third argument to strncat. Assume that str1 and str2 both contain valid strings. char str1[size1]; char str2[size2]; strncat(str1, str2, ) Part (b) [3 marks] You are asked to help with writing a C program that manages linked lists based on the following data structure: struct node { int value; struct node *next; ; Assuming that the functions to create a new node and inserting to the linked list already exist, your job is to write a function that will search through the entire linked list for a node with a particular value and will return a pointer to that node (or NULL if no such node was found). If multiple nodes with that value exist, return a pointer to the first one. The correct solution should not require more than 10 lines of code. // returns a pointer to the first node with the specified value struct node *search(struct node *head, int value) { Page 6 of 21
7 Part (c) [2 marks] Considering the following statements in a program, fill in the value for each expressions in the table below. If there is an error explain what the error is. typedef struct node{ int num; struct node *next; Node; Node a, b; Node *c; a.num=10; a.next = NULL; c = &a; c -> num = 20 b = a; b.num = 5 a.num == a.num == Part (d) [2 marks] Complete the C function below. The function returns a pointer to the first occurrence of the character c in the string s. It should return NULL if the character is not found. The correct solution should not require more than 8 lines of code. char *my_strchr(char *s, char c){ Page 7 of 21
8 Question 4 [5 marks] Part (a) [2 marks] Write the output of the following program in the correct order. Assume that all processes run until they terminate normally. int main() { int p1, p2; printf("a\n"); p1 = fork(); Output: if(p1 == 0) { printf("b\n"); p2 = fork(); if(p2 == 0) { sleep(2); printf("c\n"); exit(0); wait(0); printf("d\n"); exit(0); Part (b) [1 mark] How many processes are created, including the original process? Part (c) [2 marks] Explain how you could move one line of code of the program to a different location (i.e., describe which line of the code and where you would move it) such that as a result the last two lines of output by the program always consist of a D. Page 8 of 21
9 Question 5 [8 marks] Each of the following code fragments has a bug. Assume that the appropriate headers are included and that no external forces cause any errors, i.e. only consider errors from the program itself. For each program, explain precisely what the error is and how it could be fixed. Vague answers will not receive full marks. Part (a) [2 marks] struct node { int v; struct node *next; ; void f(struct node *n, int v) { n->v = v; n->next = NULL; int main() { int value = 10; struct node *newnode; f(newnode, value); return 0; Part (b) [2 marks] char lic_plate[7] = ABCD ; strncat(lic_plate, 314, 4); Part (c) [3 marks] int main(){ int fd[2]; char *buf1; int i; char buf2; pipe(fd); if(fork() == 0) { close(fd[1]); for(i=0; i<20; i++) { read(fd[0], buf1, 30); printf( %s\n, buf1); close(fd[0]); else { close(fd[0]); buf2 = a ; for(i=0; i<20;i++) write(fd[1], buf2, strlen(buf2)); close(fd[1]); wait(null); Page 9 of 21
10 Question 6 [10 marks] Write a C program that uses fork and pipe to set up the following pipeline and executes it. You do not need to worry about error checking. uniq < file1 wc You do not need to worry about error checking. The only systems calls you are allowed to use are open, close, dup2, pipe, execlp and fork. int fd[2], pid, filedes; if((pid = fork()) == 0) {/* child */ else if(pid > 0){ /* parent */ Page 10 of 21
11 Question 7 [8 marks] Part (a) [1 mark] When a process writes to a pipe that has already been closed it gets a SIGPIPE signal and the process terminates. Provide one line of C code that could be added to a C program that would cause the process to ignore the SIGPIPE signal. Part (b) [5 marks] Consider the following program. Assume the program runs without errors. void sig_quit(int signo) { struct sigaction newact; newact.sa_flags=0; sigemptyset(&newact.sa_mask); newact.sa_handler=sig_dfl; printf( caught SIGQUIT\n ); /*F*/ sigaction(sigquit, &newact, NULL); /*G*/ return; int main(void) { sigset_t newmask, oldmask, pendmask; struct sigaction newact; sigemptyset(&newact.sa_mask); newact.sa_handler=sig_quit; newact.sa_flags=0; /*A*/ sigaction(sigquit, &newact, NULL); sigemptyset(&newmask); sigaddset(&newmask, SIGQUIT); /*B*/ sigprocmask(sig_block, &newmask, &oldmask); sleep(10); /*C*/ if(sigismember(&pendmask, SIGQUIT)) printf( SIGQUIT pending\n ); /*D*/ sigprocmask(sig_setmask, &oldmask, NULL); /*E*/ exit(0); Page 11 of 21
12 Describe what happens if the signal SIGQUIT arrives at the process at each of the letter marks A through E. If any output is produced write it in the Output column, otherwise write NONE. Assume the program is restarted each time. A What happens Output B C D E Part (c) [2 marks] Describe what happens if the signal SIGQUIT arrives for the second time at the process at markers F and G. If any output is produced write it in the Output column, otherwise write NONE. Assume the program is restarted each time. What happens Output F G Page 12 of 21
13 Question 8 [4 marks] Part (a) [3 marks] Explain what the purpose of each of the following system calls is when setting up a socket for a server: int bind(int sockfd, struct sockaddr *addr, int addrlen) int listen(int sockfd, int n) int accept(int sockfd, struct sockaddr *addr, int *addrlen) Part (b) [1 mark] Which, if any, of the system calls above might block? Page 13 of 21
14 Question 9 [11 marks] Part (a) [5 marks] In this question you are asked to complete a client program that will open a connection to a server and then send a file to the server. The program takes two command line arguments: the first is the domain name of the host running the server, and the second is the name of the file to send to the server. The client uses socket programming to open a connection to the server and then send the file to the server. To make your task easier you can assume that the following helper function exists and can (should!) be used by your client to send the file to the server: int sendfile(int fd_in, int fd_out) sendfile keeps reading data from the file descriptor fd_in until it reaches end of file and writes all the data it reads to fd_out. Complete the client program below that sends the file to a server. You are not required to do error checking for any of the system calls. The actual number of lines of code you need to write is small (around 6 lines of code): #define SERVER_PORT 3000 int main(int argc, char* argv[]) { int soc, filedes; struct hostend *hp; struct sockaddr_in peer; peer.sin_family=pf_inet; hp=gethostbyname(argv[1]); peer.sin_port=htons(server_port); peer.sin_addr=*((struct in_addr *)hp->h_addr); /*Complete the rest of the code (no error checking required)*/ Page 14 of 21
15 Part (b) [6 marks] In this part of the question you will implement the helper function sendfile which you used in Part (a). The helper function will take as input arguments the file descriptor for the file to be sent and the file descriptor for the socket. It will use a loop to read all the data from the file in chunks of size BUFSIZ and will write all data it read to the socket. The only system calls that your sendfile implementation is allowed to use are the standard read and write system calls. You can assume that read and write always return non-negative integers, i.e. no errors occur. However, keep in mind that it is not an error if a call to read reads fewer bytes than specified, or if a call to write writes fewer bytes than specified. It s your job to check the return value of read and write, and make sure your program works correctly in those situations (i.e. all bytes from fd_in will be sent to fd_out). Complete the skeleton we provide for sendfile below. You should not need to add more than 8-10 lines of code. int sendfile(int fd_in, int fd_out){ int bytes_read, bytes_written; char buffer[bufsiz]; void *p; Page 15 of 21
16 **This page can be used if you need additional space for your answers.** Page 16 of 21
17 **This page can be used if you need additional space for your answers.** Page 17 of 21
18 **This page can be used if you need additional space for your answers.** Page 18 of 21
19 Page 19 of 21
20 Page 20 of 21
21 Page 21 of 21
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL EXAMINATIONS 2007 CSC 209H1 S St. George Campus Duration 3 hours PLEASE HAND IN Examination aids: One 8.5 x 11 sheet of paper (double-sided)
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 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 informationPLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science
PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science DECEMBER EXAMINATIONS 2006 CSC 209H1 F St. George Campus Duration 3 hours PLEASE HAND IN Student Number: Examination aids: One 8.5 x 11
More informationGood Luck! Marking Guide. APRIL 2014 Final Exam CSC 209H5S
APRIL 2014 Final Exam CSC 209H5S Last Name: Student #: First Name: Signature: UNIVERSITY OF TORONTO MISSISSAUGA APRIL 2014 FINAL EXAMINATION CSC209H5S System Programming Daniel Zingaro Duration - 3 hours
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 informationQuestion 1. Part (a) Part (b) Part (c) Part (d) Part (e) Part (f) APRIL 2012 Final Examination Solutions CSC 209H1S
Question 1. [8 marks] All of the code fragments below compile but many of them have something wrong. Check the appropriate box to indicate whether or not there is a problem and provide an explanation.
More informationContents. IPC (Inter-Process Communication) Representation of open files in kernel I/O redirection Anonymous Pipe Named Pipe (FIFO)
Pipes and FIFOs Prof. Jin-Soo Kim( jinsookim@skku.edu) TA JinHong Kim( jinhong.kim@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Contents IPC (Inter-Process Communication)
More informationCSC209H 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 informationCSC209H Lecture 8. Dan Zingaro. March 4, 2015
CSC209H Lecture 8 Dan Zingaro March 4, 2015 Signals you Already Know Like pipes, signals are a form of inter-process communication You ve already sent signals using the shell When you hit ctrl+c to terminate
More informationSystem Programming. Pipes I
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 Review Signals and files
More information15-213/18-243, Spring 2011 Exam 2
Andrew login ID: Full Name: Section: 15-213/18-243, Spring 2011 Exam 2 Thursday, April 21, 2011 v2 Instructions: Make sure that your exam is not missing any sheets, then write your Andrew login ID, full
More informationCS 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 informationWeek 13. Final exam review
Week 13. Final exam review 1. True or false? A. I claim that linked lists have the following advantages over the arrays: They allow insertion in the middle in a constant time They allow access to the element
More informationCSC209H Lecture 7. Dan Zingaro. February 25, 2015
CSC209H Lecture 7 Dan Zingaro February 25, 2015 Inter-process Communication (IPC) Remember that after a fork, the two processes are independent We re going to use pipes to let the processes communicate
More informationCS Operating system Fall Midterm I -- Oct 5, 2017 You have 75 min. Good Luck!
Name / ID (please PRINT) Seq#: Seat #: CS 3733.001 -- Operating system Fall 2017 -- Midterm I -- Oct 5, 2017 You have 75 min. Good Luck! This is a closed book/note examination. But You can use C reference
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 informationUNIX System Calls. Sys Calls versus Library Func
UNIX System Calls Entry points to the kernel Provide services to the processes One feature that cannot be changed Definitions are in C For most system calls a function with the same name exists in the
More informationPipes and FIFOs. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University
Pipes and FIFOs Woo-Yeong Jeong (wooyeong@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Open Files in Kernel How the Unix kernel represents open files? Two descriptors
More informationProcesses often need to communicate. CSCB09: Software Tools and Systems Programming. Solution: Pipes. Recall: I/O mechanisms in C
2017-03-06 Processes often need to communicate CSCB09: Software Tools and Systems Programming E.g. consider a shell pipeline: ps wc l ps needs to send its output to wc E.g. the different worker processes
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 informationPreview. Interprocess Communication with Pipe. Pipe from the Parent to the child Pipe from the child to the parent FIFO popen() with r Popen() with w
Preview Interprocess Communication with Pipe Pipe from the Parent to the child Pipe from the child to the parent FIFO popen() with r Popen() with w COCS 350 System Software, Fall 2015 1 Interprocess Communication
More informationCS 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 informationCOSC Operating Systems Design, Fall Lecture Note: Unnamed Pipe and Shared Memory. Unnamed Pipes
COSC4740-01 Operating Systems Design, Fall 2001 Lecture Note: Unnamed Pipe and Shared Memory Unnamed Pipes Pipes are a form of Inter-Process Communication (IPC) implemented on Unix and Linux variants.
More informationPreview. The pause() System Call. The pause() System Call. The signal() System Call 10/18/2017
Preview The pause() System Call The pause() System call The signal() system call Signal set The sigprocmask() system call The sigaction() system call The sigsuspend() system call The abort() system call
More informationCS 3113 Introduction to Operating Systems Midterm October 11, 2018
General instructions: CS 3113 Introduction to Operating Systems Midterm October 11, 2018 Please wait to open this exam booklet until you are told to do so. This examination booklet has 10 pages. You also
More informationCS 3113 Introduction to Operating Systems Midterm October 11, 2018
General instructions: CS 3113 Introduction to Operating Systems Midterm October 11, 2018 Please wait to open this exam booklet until you are told to do so. This examination booklet has 10 pages. You also
More informationUNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Fall Programming Assignment 1 (updated 9/16/2017)
UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Fall 2017 Programming Assignment 1 (updated 9/16/2017) Introduction The purpose of this programming assignment is to give you
More informationUNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Summer 2016 Programming Assignment 1 Introduction The purpose of this
UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Summer 2016 Programming Assignment 1 Introduction The purpose of this programming assignment is to give you some experience
More informationCSC209H Lecture 6. Dan Zingaro. February 11, 2015
CSC209H Lecture 6 Dan Zingaro February 11, 2015 Zombie Children (Kerrisk 26.2) As with every other process, a child process terminates with an exit status This exit status is often of interest to the parent
More informationIC221: Systems Programming 12-Week Written Exam [SOLUTIONS]
IC221: Systems Programming 12-Week Written Exam [SOLUTIONS] April 2, 2014 Answer the questions in the spaces provided on the question sheets. If you run out of room for an answer, continue on the back
More informationCS 550 Operating Systems Spring Inter Process Communication
CS 550 Operating Systems Spring 2019 Inter Process Communication 1 Question? How processes communicate with each other? 2 Some simple forms of IPC Parent-child Command-line arguments, wait( ), waitpid(
More informationPrepared 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 informationProcess. 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 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 informationProcess 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 informationCGS 3460 Summer 07 Midterm Exam
Short Answer 3 Points Each 1. What would the unix command gcc somefile.c -o someotherfile.exe do? 2. Name two basic data types in C. 3. A pointer data type holds what piece of information? 4. This key
More informationProcess Management 1
Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Programmatically redirecting stdin, stdout, and stderr (Appendix) communication between processes via pipes Why?
More informationCS Operating system Spring Final -- May 8, You have 120 min. Good Luck!
Name / ID (please PRINT) Sequence #: Seat Number: CS 3733.001 -- Operating system Spring 2017 -- Final -- May 8, 2017 @9:45am You have 120 min. Good Luck! This is a closed book/note examination. But You
More informationWindows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.
Structure Unix architecture users Functions of the System tools (shell, editors, compilers, ) standard library System call Standard library (printf, fork, ) OS kernel: processes, memory management, file
More informationContents. PA1 review and introduction to PA2. IPC (Inter-Process Communication) Exercise. I/O redirection Pipes FIFOs
Pipes and FIFOs Prof. Jin-Soo Kim( jinsookim@skku.edu) TA Dong-Yun Lee(dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Contents PA1 review and introduction to
More informationCSC209H1S Day Midterm Solutions Winter 2010
Duration: Aids Allowed: 50 minutes 1-8.5x11 sheet Student Number: Last Name: SOLUTION First Name: Instructor: Karen Reid Do not turn this page until you have received the signal to start. (In the meantime,
More informationProcess Management! Goals of this Lecture!
Process Management! 1 Goals of this Lecture! Help you learn about:" Creating new processes" Programmatically redirecting stdin, stdout, and stderr" Unix system-level functions for I/O" The Unix stream
More informationCS240: 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 informationFinal Precept: Ish. Slides Originally Prepared by: Wonho Kim
Final Precept: Ish Slides Originally Prepared by: Wonho Kim Agenda Last time exec(), fork() wait() Today zombie, orphan process built-in commands in ish I/O redirection Unix signal Process Hierarchy Every
More informationPorts under 1024 are often considered special, and usually require special OS privileges to use.
1 2 Turns out that besides an IP address (used by the IP layer), there is another address that is used by TCP (stream sockets) and, coincidentally, by UDP (datagram sockets). It is the port number. It's
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 Internet Connections (1) 2 Connection Clients and servers communicate by sending streams of bytes over
More informationCOM324 System Programming. Midterm Exam
Name: COM324 System Programming Spring 2009-2010 Computer Engineering Department Near East University Midterm Exam April 28, 2010 [11:30A] Lecturer: Hüseyin Sevay INSTRUCTIONS You have 100 minutes for
More informationUNIVERSITY OF WINDSOR Fall 2007 QUIZ # 2 Solution. Examiner : Ritu Chaturvedi Dated :November 27th, Student Name: Student Number:
UNIVERSITY OF WINDSOR 60-106-01 Fall 2007 QUIZ # 2 Solution Examiner : Ritu Chaturvedi Dated :November 27th, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.
More informationWorkshop on Inter Process Communication Solutions
Solutions 1 Background Threads can share information with each other quite easily (if they belong to the same process), since they share the same memory space. But processes have totally isolated memory
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 informationOperating Systems and Networks Assignment 2
Spring Term 2014 Operating Systems and Networks Assignment 2 Assigned on: 27th February 2014 Due by: 6th March 2014 1 Scheduling The following table describes tasks to be scheduled. The table contains
More informationCSI Module 2: Processes
CSI3131 - Module 2: es Reading: Chapter 3 (Silberchatz) Objective: To understand the nature of processes including the following concepts: states, the PCB (process control block), and process switching.
More informationCMSC 313 Spring 2010 Exam 3 May 17, 2010
CMSC 313 Spring 2010 Exam 3 May 17, 2010 Name Score UMBC Username Notes: a. Please write clearly. Unreadable answers receive no credit. b. There are no intentional syntax errors in any code provided with
More informationFirst 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 informationFinal Exam 1 /12 2 /12 3 /10 4 /7 5 /4 6 /10 7 /8 8 /9 9 /8 10 /11 11 /8 12 /10 13 /9 14 /13 15 /10 16 /10 17 /12. Faculty of Computer Science
Faculty of Computer Science Page 1 of 21 Final Exam Term: Fall 2018 (Sep4-Dec4) Student ID Information Last name: First name: Student ID #: CS.Dal.Ca userid: Course ID: CSCI 2132 Course Title: Instructor:
More informationUNIX Sockets. Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E.
UNIX Sockets Developed for the Azera Group By: Joseph D. Fournier B.Sc.E.E., M.Sc.E.E. Socket and Process Communication application layer User Process Socket transport layer (TCP/UDP) network layer (IP)
More informationNETWORK 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 informationCSE 124 Discussion Section Sockets Programming 10/10/17
CSE 124 Discussion Section Sockets Programming 10/10/17 Topics What s a socket? Creating a socket Connecting a socket Sending data Receiving data Resolving URLs to IPs Advanced socket options Live code
More informationTutorial on Socket Programming
Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Hao Wang (Slides are mainly from Seyed Hossein Mortazavi, Monia Ghobadi, and Amin Tootoonchian, ) 1 Outline Client-server
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 informationComputer Systems Assignment 2: Fork and Threads Package
Autumn Term 2018 Distributed Computing Computer Systems Assignment 2: Fork and Threads Package Assigned on: October 5, 2018 Due by: October 12, 2018 1 Understanding fork() and exec() Creating new processes
More informationServer-side Programming
Server-side Programming CSE 333 Spring 2018 Instructor: Justin Hsia Teaching Assistants: Danny Allen Dennis Shao Eddie Huang Kevin Bi Jack Xu Matthew Neldam Michael Poulain Renshu Gu Robby Marver Waylon
More informationInter-process communication (IPC)
Inter-process communication (IPC) Operating Systems Kartik Gopalan References Chapter 5 of OSTEP book. Unix man pages Advanced Programming in Unix Environment by Richard Stevens http://www.kohala.com/start/apue.html
More informationSection 2: Processes
September 7, 2016 Contents 1 Warmup 2 1.1 Hello World............................................ 2 2 Vocabulary 2 3 Problems 3 3.1 Forks................................................ 3 3.2 Stack Allocation.........................................
More information10. I/O System Library
10. I/O System Library Header File #include // Found in C:\Nburn\include General File Descriptor Functions close --- Close open file descriptors read --- Read data from a file descriptor ReadWithTimeout
More informationCS240: Programming in C
CS240: Programming in C Lecture 16: Process and Signals Cristina Nita-Rotaru Lecture 16/ Fall 2013 1 Processes in UNIX UNIX identifies processes via a unique Process ID Each process also knows its parent
More informationOutline. Distributed Computer Systems. Socket Basics An end-point for a IP network connection. Ports. Sockets and the OS. Transport Layer.
Outline Distributed Computer Systems Socket basics Socket details (TCP and UDP) Socket options Final notes Sockets Socket Basics An end-point for a IP network connection what the application layer plugs
More informationCS 33. Architecture and the OS. CS33 Intro to Computer Systems XIX 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.
CS 33 Architecture and the OS CS33 Intro to Computer Systems XIX 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. The Operating System My Program Mary s Program Bob s Program OS CS33 Intro to
More informationCS 470 Operating Systems Spring 2013 Shell Project
CS 470 Operating Systems Spring 2013 Shell Project 40 points Out: January 11, 2013 Due: January 25, 2012 (Friday) The purpose of this project is provide experience with process manipulation and signal
More informationOperating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line
Operating Systems Lecture 06 System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line March 04, 2013 exec() Typically the exec system call is
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 informationCS 33. Architecture and the OS. CS33 Intro to Computer Systems XIX 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.
CS 33 Architecture and the OS CS33 Intro to Computer Systems XIX 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. The Operating System My Program Mary s Program Bob s Program OS CS33 Intro to
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 informationCS 3214 Final Exam. To be considerate to your fellow students, if you leave early, do so with the least amount of noise.
CS 3214 This is a closed-book, closed-internet, closed-cell phone and closed-computer exam. However, you may refer to your prepared notes on 1 double-sided page. Your exam should have 11 pages with 4 topics
More informationAssignment 1. Teaching Assistant: Michalis Pachilakis (
Assignment 1 Teaching Assistant: Michalis Pachilakis ( mipach@csd.uoc.gr) System Calls If a process is running a user program in user mode and needs a system service, such as reading data from a file,
More informationIntroduction to Computer Systems. Exam 2. April 11, Notes and calculators are permitted, but not computers.
15-213 Introduction to Computer Systems Exam 2 April 11, 2006 Name: Andrew User ID: Recitation Section: Model Solution fp This is an open-book exam. Notes and calculators are permitted, but not computers.
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 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 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 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 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 informationThe Process Abstraction. CMPU 334 Operating Systems Jason Waterman
The Process Abstraction CMPU 334 Operating Systems Jason Waterman How to Provide the Illusion of Many CPUs? Goal: run N processes at once even though there are M CPUs N >> M CPU virtualizing The OS can
More informationYork 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 informationSelect the statements below which accurately describe the operation of this system. This system hangs without producing output.
Consider the following code fragment. int fd[2]; char ch; pipe(fd); write(fd[1],"ab",2); if (fork() == 0) { read(fd[0],&ch,1); write(1,&ch,1); else{ read(fd[0],&ch,1); write(1,&ch,1); Select the statements
More informationCOP 3223 Introduction to Programming with C - Study Union - Fall 2017
COP 3223 Introduction to Programming with C - Study Union - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................
More informationCOP4342 UNIX Tools Assignment #3: A Simple Unix Shell. Instructor: Dr. Robert Van Engelen Teaching Assistant: Imran Chowdhury Spring 2018
Total Points: 100 COP4342 UNIX Tools Assignment #3: A Simple Unix Shell Instructor: Dr. Robert Van Engelen Teaching Assistant: Imran Chowdhury Spring 2018 Description: The bash shell utility on UNIX and
More informationStudent Number: Instructor: Reid Section: L0101 (10:10-11:00am)
Midterm Test Duration 50 minutes Aids allowed: none Last Name: Student Number: First Name: Instructor: Reid Section: L0101 (10:10-11:00am) Do not turn this page until you have received the signal to start.
More informationProcess Management! Goals of this Lecture!
Process Management! 1 Goals of this Lecture! Help you learn about:" Creating new processes" Programmatically redirecting stdin, stdout, and stderr" (Appendix) communication between processes via pipes"
More informationLike select() and poll(), epoll can monitor multiple FDs epoll returns readiness information in similar manner to poll() Two main advantages:
Outline 22 Alternative I/O Models 22-1 22.1 Overview 22-3 22.2 Nonblocking I/O 22-5 22.3 Signal-driven I/O 22-11 22.4 I/O multiplexing: poll() 22-14 22.5 Problems with poll() and select() 22-31 22.6 The
More informationOutline. Operating Systems. Socket Basics An end-point for a IP network connection. Ports. Network Communication. Sockets and the OS
Outline Operating Systems Socket basics Socket details Socket options Final notes Project 3 Sockets Socket Basics An end-point for a IP network connection what the application layer plugs into programmer
More informationCreating a Shell or Command Interperter Program CSCI411 Lab
Creating a Shell or Command Interperter Program CSCI411 Lab Adapted from Linux Kernel Projects by Gary Nutt and Operating Systems by Tannenbaum Exercise Goal: You will learn how to write a LINUX shell
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 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 informationMaria Hybinette, UGA. ! One easy way to communicate is to use files. ! File descriptors. 3 Maria Hybinette, UGA. ! Simple example: who sort
Two Communicating Processes Hello Gunnar CSCI 6730/ 4730 Operating Systems Process Chat Maria A Hi Nice to Hear from you Process Chat Gunnar B Dup & Concept that we want to implement 2 On the path to communication
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 informationLecture 8: Unix Pipes and Signals (Feb 10, 2005) Yap
Lecture 8: Unix Pipes and Signals (Feb 10, 2005) Yap February 17, 2005 1 ADMIN Our Grader will be Mr. Chien-I Liao (cil217@nyu.edu). Today s Lecture, we will go into some details of Unix pipes and Signals.
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 informationIntroduction. This project will focus primarily on processes.
Project 2 Processes Introduction This project will focus primarily on processes. In this project, you will become familiar with: 1. Locks for kernel-level data structures; concurrency. 2. Implementing
More information