NETWORK PROGRAMMING TOTAL = 45

Size: px
Start display at page:

Download "NETWORK PROGRAMMING TOTAL = 45"

Transcription

1 MC9241 NETWORK PROGRAMMING L T P C UNIT I - INTRODUCTION 9 Introduction Overview of UNIX OS - Environment of a UNIX process - Process control - Process relationships Signals Interprocess Communication- overview of TCP/IP Protocols. UNIT II - ELEMENTARY TCP SOCKETS 9 Introduction to Socket Programming Introduction to Sockets Socket address Structures Byte ordering functions address conversion functions Elementary TCP Sockets socket, connect, bind, listen, accept, read, write, close functions Iterative Server Concurrent Server. UNIT III - APPLICATION DEVELOPMENT 9 TCP Echo Server TCP Echo Client Posix Signal handling Server with multiple clients boundary conditions: Server process Crashes, Server host Crashes, Server Crashes and reboots, Server Shutdown I/O multiplexing I/O Models select function shutdown function TCP echo Server (with multiplexing) poll function TCP echo Client (with Multiplexing). UNIT IV - SOCKET OPTIONS, ELEMENTARY UDP SOCKETS 9 Socket options getsocket and setsocket functions generic socket options IP socket options ICMP socket options TCP socket options Elementary UDP sockets UDP echo Server UDP echo Client Multiplexing TCP and UDP sockets Domain name system gethostbyname function Ipv6 support in DNS gethostbyadr function getservbyname and getservbyport functions. UNIT V ADVANCED SOCKETS 9 Ipv4 and Ipv6 interoperability threaded servers thread creation and termination TCP echo server using threads Mutexes condition variables raw sockets raw socket creation raw socket output raw socket input ping program trace route program. TOTAL = 45 REFERENCES: 1. W. Richard Stevens, Advanced Programming in The UNIX Environment, Addison Wesley, W. Richard Stevens, UNIX Network Programming - Volume 1, Prentice Hall International, CCET

2 Introduction UNIX UNIX has been a popular OS for more than two decades because of its multi-user, multi-tasking environment, stability, portability and powerful networking capabilities as shown in the below figure. In the late 1960s, researchers from General Electric, MIT and Bell Labs launched a joint project to develop an ambitious multi-user, multi-tasking OS for mainframe computers known as MULTICS (Multiplexed Information and Computing System). MULTICS failed, but it did inspire Ken Thompson, who was a researcher at Bell Labs, to have a go at writing a simpler operating system himself. He wrote a simpler version of MULTICS on a PDP7 in assembler and called his attempt UNICS (Uniplexed Information and Computing System). Because memory and CPU power were at a premium in those days, UNICS (eventually shortened to UNIX) used short commands to minimize the space needed to store them and the time needed to decode them- hence the tradition of short UNIX commands we use today, example: ls, cp, rm, mv etc. Ken Thompson then teamed up with Dennis Ritchie, the author of the first C compiler in 1973.They rewrote the UNIX kernel in C - this was a big step forwards in terms of the system's portability - and released the Fifth Edition of UNIX to universities in CCET

3 The Seventh Edition, released in 1978, marked a split in UNIX development into two main branches: SYSV (System5) and BSD (Berkeley Software Distribution). BSD arose from the University of California at Berkeley where Ken Thompson spent a sabbatical year. Its development was continued by students at Berkeley and other research institutions. SYSV was developed by AT&T and other commercial companies. UNIX flavors based on SYSV have traditionally been more conservative, but better supported than BSD-based flavors. The latest incarnations of SYSV (SVR4 or System 5 Release 4) and BSD Unix are actually very similar. Overview of UNIX OS Introduction UNIX is multi-user and multi-tasking operating system. Multi-tasking: Multiple processes can run concurrently. Example, different users can read mails, copy files, and print all at once. Logging In Enter login name and password! System password file: /etc/passwd (usually). You can change password using the command: passwd. Shell After a successful login, the shell program is run. The default shell of bingsuns: tcsh bingsun2% ps PID TTY TIME CMD 2159 pts/2 0:00 tcsh Shell is a command line interpreter that reads user commands and executes them. Unix Shells Common Shells: Bourne shell, the C shell, and the Korn shell. The shell on bingsuns is tcsh (tc shell). Users can switch between shells, using the commands bash, csh, ksh, sh. Control D (^d) to return back to original shell, or just use the command: exit. Some shell commands Most Important command: man (manual pages). Help: unix commands, C functions. 3 CCET

4 Usage: man <command/function> Try man man! Example: manls, man passwd, man printf. pwd: working directory (/u0/users/2/kliu1). ls: list contents of directory mkdir<dir-name>: make directory rmdir<dir-name>: remove an empty directory rm r <dir-name>: remove a directory with all the contents cd <directory>: change directory, ~/ means your home directory cp<source><target>: copy command. chmod<mode><filename>: change mode of a file/directory ls l <directory or filename>: long list with details 9 permission bits: d r w x r w x r w x 3 categories: user/group/all. Permissions: read/write/execute (r/w/x). E.g.: mode= 644 means r w _ r r command: chmod 644 <filename> first 3 bits for user. Next group. Next all others rm<option><filename>: remove files e.g.: rm fr directory/filename mv <old><new>: change the name of a file Pipes: Connect the stdout of one command with the stdin of another command e.g.: ls -l more orls l less File System Hierarchical arrangement of files and directories. Top level: root or / e.g.: cd /. Current directory,.. One level higher directory e.g.: cd.no change for it is current directory or cd.. Change to parent directory. 4 CCET

5 Pathname: absolute and relative. Absolute pathname: /u0/users/2/kliu1 Relative pathname: abc. Editors Different editors: emacs, pico, vi emacs<filename> pico<filename> vi <filename> The easiest editor: pico or nano pico<filename> Full screen editor Help on the bottom of the screen The nano is an extension to the pico ARCHITECTURE OF THE UNIX SYSTEM The below figure depicts the high level architecture of UNIX system. 5 CCET

6 The Kernel The kernel is the part of the operating system that interacts directly with the hardware of a computer, through device drivers that are built into the kernel. It provides sets of services that can be used by programs, insulating these programs from the underlying hardware. The major functions of the kernel are to manage computer memory, to control access to the computer, to maintain the file system, to handle interrupts (signals to terminate execution), to handle errors, to perform input and output services (which allow computers to interact with terminals, storage devices, and printers), and to allocate the resources of the computer (such as the CPU or input/output devices) among users. Programs interact with the kernel through system calls. System calls tell the kernel to carry out various tasks for the program, such as opening a file, writing to a file, obtaining information about a file, executing a program, terminating a process, changing the priority of a process, and getting the time of day Different implementations of a variant of the UNIX system may have compatible system calls, with each call having the same functionality However, the internals, programs that perform the functions of system calls (usually written in the C language), and the system architecture in two different UNIX variants or even two different implementations of a particular UNIX variant may bear little resemblance to one another. SALIENT FEATURES OF UNIX The system is written in a high level language, making it easy to read, understand, change and move to other machine. It has simpler user interface that has the power to provide the services that users want. It provides primitives that permit complex programs to be built from the simpler programs. It uses hierarchical file systems that allow easy maintenance and efficient implementation. Multi-user Capability 6 CCET

7 Multi-tasking Capability It hides the machine architecture from the user, making it easier to write programs thatrun on different hardware implementations. It has excellent provision for communication with fellow users. Environment of a UNIX Process Program & Process Program is an executable file that resides on the disk. Process is an executing instance of a program. A Unix process is identified by a unique non-negative integer called the process ID. Check process status using the ps command. Foreground/background processes A program run using the ampersand operator & creates a background process. E.g.: bingsun2% back & otherwise it creates a foreground process. E.g.: bingsun2% back How to stop a process? Foreground processes can generally be stopped by pressing CONTROL C (^C). Background processes can be stopped using the kill command. Usage: kill SIGNAL <process id list> kill -9 <process id list> (-9 means no blocked)or kill <process id list>. If a foreground process is not stopping by ^C, you can open another session and use the kill command. The Environment of a Unix Process Objective: How main function is called when program is executed. How program terminates execution How command-line arguments are passed What the typical memory layout is Alloc memory, use environment variables,. main function intmain(intargc, char *argv[]) -- prototype When program is started by kernel, a special start-up routine is called before calling main(). Start-up routine is set up by the link editor as part of 7 CCET

8 the executable. Start-up routine takes command-line arguments and environment variable to prepare execution of main function. How a C program is started and terminated? Historically, a C program has been composed of the following pieces: Text segment, the machine instructions that the CPU executes. Usually, the text segment is sharable so that only a single copy needs to be in memory for frequently executed programs, such as text editors, the C compiler, the shells, and so on. Also, the text segment is often read-only, to prevent a program from accidentally modifying its instructions. Initialized data segment, usually called simply the data segment, containing variables that are specifically initialized in the program. For example, the C declaration int maxcount = 99; appearing outside any function causes this variable to be stored in the initialized data segment with its initial value. Uninitialized data segment, often called the "bss" segment, named after an ancient assembler operator that stood for "block started by symbol." Data in this segment is initialized by the kernel to arithmetic 0 or null pointers before the program starts executing. The C declaration long sum[1000]; 8 CCET

9 appearing outside any function causes this variable to be stored in the uninitialized data segment. Stack, where automatic variables are stored, along with information that is saved each time a function is called. Each time a function is called, the address of where to return to and certain information about the caller's environment, such as some of the machine registers, are saved on the stack. The newly called function then allocates room on the stack for its automatic and temporary variables. This is how recursive functions in C can work. Each time a recursive function calls itself, a new stack frame is used, so one set of variables doesn't interfere with the variables from another instance of the function. Heap, where dynamic memory allocation usually takes place. Historically, the heap has been located between the uninitialized data and the stack. Figure shows the typical arrangement of these segments. This is a logical picture of how a program looks; there is no requirement that a given implementation arrange its memory in this fashion. Nevertheless, this gives us a typical arrangement to describe. With Linux on an Intel x86 processor, the text segment starts at location 0x , and the bottom of the stack starts just below 0xC (The stack grows from higher-numbered addresses to lower-numbered addresses on this particular architecture.) The unused virtual address space between the top of the heap and the top of the stack is large. Several more segment types exist in an a.out, containing the symbol table, debugging information, linkage tables for dynamic shared libraries, and the like. These additional sections don't get loaded as part of the program's image executed by a process. 9 CCET

10 Process Control PROCESS RELATED SYSTEM CALLS In addition to the process ID, there are other identifiers for every process. The following functions return these identifiers. It is very simple to print the PID of a running process programmatically. Here is the program that achieves this /* pid.c */ int main( ) { printf ( "Process ID = %d", getpid( ) ) ; } Here getpid( ) is a library function which returns the process ID of the calling process. When the execution of the program comes to an end the process stands terminated. Every time we run the program a new process is created. Hence the kernel assigns a new ID to the process each time. This can be verified by executing the program several times each time it would produce a different output. fork Function As we know, our running program is a process. From this process we can create another process. There is a parent-child relationship between the two processes. The way to achieve this is by using a library function called fork( ). This function splits the running process into two processes, the existing one is known as parent and the new process is known as child. An existing process can create a new one by calling the fork function. #include <unistd.h> pid_t fork(void); Returns: 0 in child, process ID of child in parent, 1 on error The only difference in the returns is that the return value in the child is 0, whereas the return value in the parent is the process ID of the new child. The reason the child's process ID is returned to the parent is that a process can have more than one child, and there is no function that allows a process to obtain the process IDs of its children. The reason fork returns 0 to the child is that a process can have only a single parent, and the child can always call getppid to obtain the process ID of its parent. (Process ID 0 is reserved for use by the kernel, so it's not possible for 0 to be the process ID of a child.) 10 CCET

11 Both the child and the parent continue executing with the instruction that follows the call to fork. The child is a copy of the parent. For example, the child gets a copy of the parent's data space, heap, and stack. Note that this is a copy for the child; the parent and the child do not share these portions of memory. The parent and the child share the text segment /* forkexample.c */ # include <sys/types.h> int main( ) { printf ( "Before Forking\n" ) ; fork( ) ; printf ( "After Forking\n" ) ; } Here is the output of the program Before Forking After Forking After Forking Watch the output of the program. You can notice that all the statements after the fork( ) are executed twice once by the parent process and second time by the child process. In other words fork( ) has managed to split our process into two. Indeed, one characteristic of fork is that all file descriptors that are open in the parent are duplicated in the child. We say "duplicated" because it's as if the dup function had been called for each descriptor. The parent and the child share a file table entry for every open descriptor. Consider a process that has three different files opened for standard input, standard output, and standard error. On return from fork, we have the arrangement shown in below figure. 11 CCET

12 If both parent and child write to the same descriptor, without any form of synchronization, such as having the parent wait for the child, their output will be intermixed (assuming it's a descriptor that was open before the fork). Although this is possible we saw it in above figure but it's not the normal mode of operation. There are two normal cases for handling the descriptors after a fork. 1. The parent waits for the child to complete. In this case, the parent does not need to do anything with its descriptors. When the child terminates, any of the shared descriptors that the child read from or wrote to will have their file offsets updated accordingly. 2. Both the parent and the child go their own ways. Here, after the fork, the parent closes the descriptors that it doesn't need, and the child does the same thing. This way, neither interferes with the other's open descriptors. This scenario is often the case with network servers. vfork Function The function vfork has the same calling sequence and same return values as fork. But the semantics of the two functions differ. The vfork function is intended to create a new process when the purpose of the new process is to exec a new program. The vfork function creates the new process, just like 12 CCET

13 fork, without copying the address space of the parent into the child, as the child won't reference that address space; the child simply calls exec (or exit) right after the vfork. Instead, while the child is running and until it calls either exec or exit, the child runs in the address space of the parent. This optimization provides an efficiency gain on some paged virtual-memory implementations of the UNIX System. Another difference between the two functions is that vfork guarantees that the child runs first, until the child calls exec or exit. When the child calls either of these functions, the parent resumes. (This can lead to deadlock if the child depends on further actions of the parent before calling either of these two functions.) /* vforkexample.c */ #include <stdio.h> #include<sys/types.h> int glob=6; int main(void) { int var=88; pid_t pid; printf("\nvfork Function"); printf("\n~~~~~~~~~~~~~~~"); printf("\nbefore vfork\n"); if((pid=vfork())<0) printf("\nvfork error"); else if(pid==0) { glob++; var++; _exit(0); } printf("\npid=%d\nglob=%d\nvar=%d\n",getpid(),glob,var); exit(0); } exit Functions A process can terminate normally in five ways: 1. Executing a return from the main function. 2. Calling the exit function.. 3. Calling the _exit or _Exit function. 4. Executing a return from the start routine of the last thread in the process. 5. Calling the pthread_exit function from the last thread in the process. The three forms of abnormal termination are as follows: 1. Calling abort. This is a special case of the next item, as it generates the SIGABRT signal. 13 CCET

14 2. When the process receives certain signals. The signal can be generated by the process itself for example, by calling the abort function by some other process, or by the kernel. Examples of signals generated by the kernel include the process referencing a memory location not within its address space or trying to divide by The last thread responds to a cancellation request. By default, cancellation occurs in a deferred manner: one thread requests that another be canceled, and sometime later, the target thread terminates. Regardless of how a process terminates, the same code in the kernel is eventually executed. This kernel code closes all the open descriptors for the process, releases the memory that it was using, and the like. wait and waitpid Functions When a process terminates, either normally or abnormally, the kernel notifies the parent by sending the SIGCHLD signal to the parent. Because the termination of a child is an asynchronous event it can happen at any time while the parent is running this signal is the asynchronous notification from the kernel to the parent. The parent can choose to ignore this signal, or it can provide a function that is called when the signal occurs: a signal handler. The default action for this signal is to be ignored. A process that calls wait or waitpid can Block, if all of its children are still running Return immediately with the termination status of a child, if a child has terminated and is waiting for its termination status to be fetched Return immediately with an error, if it doesn't have any child processes If the process is calling wait because it received the SIGCHLD signal, we expect wait to return immediately. But if we call it at any random point in time, it can block. #include <sys/wait.h> pid_t wait(int *statloc); pid_t waitpid(pid_t pid, int *statloc, int options); Both return: process ID if OK, 0 (see later), or 1 on error. The interpretation of the pid argument for waitpid depends on its value: pid == 1 Waits for any child process. In this respect, waitpid is equivalent to wait. pid > 0 Waits for the child whose process ID equals pid. exec Functions As we mentioned in earlier that one use of the fork function is to create a new process (the child) that then causes another program to be executed by calling one of the exec functions. When a process calls one of the exec functions, that process is completely replaced by the new program, and the new program starts executing at its main function. The process ID does not change across an exec, because a new process is not created; exec merely replaces the current process its text, data, heap, and stack segments with a brand new program 14 CCET

15 from disk.pid == 1 Waits for any child process. In this respect, waitpid is equivalent to wait. pid == 0 Waits for any child whose process group ID equals that of the calling process. pid < 1 Waits for any child whose process group ID equals the absolute value of pid. process Relationships signals Process relationships Two major relations govern individual processes Process groups Sessions Information on these relationships is available through the ps command when using the proper option flags. Relationship of the six exec functions Example Program 10 */ /* Prepared by Mr.A.Saleem Raja on */ /* execlexample.c */ # include <unistd.h> int main( ) { int pid ; pid = fork( ) ; if ( pid == 0 ) { execl ( "/bin/ls","-al", "/etc", NULL ) ; printf ( "Child: After exec( )\n") ; } else printf ( "Parent process\n" ) ; } system Function It is convenient to execute a command string from within a program. For example, assume that we want to put a time-and-date stamp into a certain file. system("date > file"); ISO C defines the system 15 CCET

16 function, but its operation is strongly system dependent. POSIX.1 includes the system interface, expanding on the ISO C definition to describe its behavior in a POSIX environment. Changing User IDs and Group IDs We can set the real user ID and effective user ID with the setuid function. Similarly, we can set the real group ID and the effective group ID with the setgid function. #include <unistd.h> int setuid(uid_t uid); int setgid(gid_t gid); Both return: 0 if OK, 1 on error User Identification The system normally keeps track of the name we log in with help of the two data files that have been provided with most UNIX systems are the utmp file, which keeps track of all the users currently logged in, and the wtmp file, which keeps track of all logins and logouts. The get login function provides a way to fetch that login name. #include <unistd.h> char *getlogin(void); Returns: pointer to string giving login name if OK, NULL on error This function can fail if the process is not attached to a terminal that a user logged in to. We normally call these processes daemons. Inter process Communication Inter-process communication (IPC) is the transfer of data among processes. Processes incomputer memory are said to be communicating with one process passes data to anotheror vice versa. UNIX provides a number of ways to share and communicate data. They are Pipes Signals Message Queues Semaphores Shared Memory Sockets Pipes We use the word pipe when we connect a data flow from one process to another. Shellcommands can be linked together so that the output of one process is fed straight to theinput of another.pipes are the oldest form of UNIX System IPC and are provided by all UNIX systems.pipes have two limitations. Historically, they have been half duplex (i.e., data flows in only one direction).some systems now provide full-duplex pipes, but for maximum portability, weshould never assume that this is the case.2. Pipes can be used only between processes that have a common ancestor.normally, a pipe is 16 CCET

17 created by a process, that process calls fork, and the pipe isused between the parent and the child. Despite these limitations, half-duplex pipes are still the most commonly used form ofipc. Every time you type a sequence of commands in a pipeline for the shell to execute,the shell creates a separate process for each command and links the standard output ofone to the standard input of the next using a pipe. Signals Signals are one of the oldest inter-process communication methods used by Unix systems. They are used to signal asynchronous events to one or more processes. A signal could be generated by a keyboard interrupt or an error condition such as the process attempting to access a non-existent location in its virtual memory. Signals are also used by the shells to signal job control commands to their child processes. There are a set of defined signals that the kernel can generate or that can be generated by other processes in the system, provided that they have the correct privileges. You can list a system's set of signals using the kill command (kill -l:) 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGIOT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR Message Queues A message queue is a linked list of messages stored within the kernel and identified by a message queue identifier. Message queues provide a way of sending a block of data from one process to another. Message queues allow one or more processes to write messages, which will be read by one or more reading processes. i.e. Two (or more) processes can exchange information via access to a common system message queue. The sending process places via some (OS) message-passing module a message onto a queue which can be read by another process. Each message is given an identification or type so that processes can select the appropriate message. Process must share a common key in order to gain access to the queue in the first place. 17 CCET

18 Each queue has the following msqid_dsstructure associated with it: Semaphores Semaphores are a programming construct designed by E. W. Dijkstra in the late 1960s.Dijkstra's model was the operation of railroads: consider a stretch of railroad in which there is a single track over which only one train at a time is allowed. Guarding this track is a semaphore. A train must wait before entering the single track until the semaphore is in a state that permits travel. When the train enters the track, the semaphore changes state to prevent other trains from entering the track. A train that is leaving this section of track must again change the state of the semaphore to allow another train to enter. In the computer version, a semaphore appears to be a simple integer. A process (or a thread)waits for permission to proceed by waiting for the integer to become 0. The signal if it proceeds signals that this by performing incrementing the integer by 1. When it is finished, the process changes the semaphore's value by subtracting one from it. Here are the signal notations: P ( Semaphore variable) for wait. V ( Semaphore variable) for signal. Semaphore Definition A binary semaphore is a variable that can take only the values 0 and 1. The definition of p and v are surprisingly simple. Suppose we have a semaphore variable,sv. The two operations are then defined as: 18 CCET

19 Shared Memory Shared memory allows two or more processes to share a given region of memory. This isthe fastest form of IPC, because the data does not need to be copied between the clientand the server. The only trick in using shared memory is synchronizing access to a givenregion among multiple processes. If the server is placing data into a shared memoryregion, the client shouldn't try to access the data until the server is done. Often,semaphores are used to synchronize shared memory access. Overview of TCP/IP Protocols TCP/IP Protocol Suite The TCP/IP protocol suite was first defined in 1974 The TCP/IP protocol suite is the protocol architecture of the Internet The TCP/IP suite has four layers: Application, Transport, Internet, and Network Interface Layer. 19 CCET

20 Internet is viewed as a communication infrastructure that enables distributed applications like e mail, games, and e commerce. The protocol used in the internet is TCP/IP.TCP/IP is a suite of protocols, also known as the Internet Protocol Suite. It should not be confused with the OSI reference model, although elements of TCP/IP exist in OSI. The transmission control protocol and the internet protocol are fundamental to the suite, hence the TCP/IP title. The suite was originally developed for the US Department of Defense Advanced Research Project Agency (DARPA) network, but it is now the basis for the Internet and many intranets. As with the OSI model, the TCP/IP suite uses a layered model. The OSI model has seven layers while the TCP/IP model has four or five some authors call it a four layer suite - Application, Transport, Internet and Network Access layers and others split the Network Access layer into its Physical and Data link components. The functionality of each layer and some of the protocols that comprise the TCP/IP model are explained here. 20 CCET

21 Layers 1 and 2 - Network Access: The combination of physical and data link layers deals with pure hardware (wires, satellite links, network interface cards, etc.) and access methods such as CSMA/CD (carrier sensed multiple access with collision detection). Ethernet exists at the network access layer - its hardware operates at the physical layer and its medium access control method (CSMA/CD) operates at the data link layer. Each system has a physical address for the operation by this layer. Layer 3 Internet: This layer is responsible for the routing and delivery of data across networks. It allows communication across networks of the same and different types and carries out translations to deal with dissimilar data addressing schemes. IP (Internet Protocol) and ARP (Address Resolution Protocol) are both to be found at the Internet layer. Each system has a physical address corresponds to the operation at this layer. Each system has a logical address called as IP address used by this layer. Layer 4 Transport: The transport layer is similar to the OSI transport model, but with elements of the OSI session layer functionality. This layer provides an application layer delivery service. The two protocols found at the transport layer are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol). Either of these two protocols are used by the application layer process depends on the application's transmission reliability requirements. Each system has many port addresses corresponding to the various services provided at this layer. TCP is a reliable, connection-oriented protocol that provides error checking and flow control through a virtual link that it establishes and finally terminates. This gives a reliable service, therefore TCP would be utilized by FTP and SNMP - file transfer and delivery have to be accurate and error free. UDP is an unreliable, connectionless protocol that provides data transport with lower network traffic overheads than TCP - UDP does not error check or offer any flow 21 CCET

22 control, this is left to the application process. SNMP uses UDP - SNMP is used to monitor network performance, so its operation must not contribute to congestion. Layer 5 Application: This layer is broadly equivalent to the application, presentation and session layers of the OSI model. It gives an application access to the communication environment. Examples of protocols found at this layer are Telnet, FTP (File Transfer Protocol), SNMP (Simple Network Management Protocol), HTTP (Hyper Text Transfer Protocol) and SMTP (Simple Mail Transfer Protocol). Comparison of OSI Model and TCP/IP Suite 22 CCET

System Programming. Introduction to Unix

System Programming. Introduction to Unix 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 Introduction 2 3 Introduction

More information

CSE 410: Computer Systems Spring Processes. John Zahorjan Allen Center 534

CSE 410: Computer Systems Spring Processes. John Zahorjan Allen Center 534 CSE 410: Computer Systems Spring 2018 Processes John Zahorjan zahorjan@cs.washington.edu Allen Center 534 1. What is a process? Processes 2. What's the process namespace? 3. How are processes represented

More information

System Calls and Signals: Communication with the OS. System Call. strace./hello. Kernel. Context Switch

System Calls and Signals: Communication with the OS. System Call. strace./hello. Kernel. Context Switch System Calls and Signals: Communication with the OS Jonathan Misurda jmisurda@cs.pitt.edu System Call An operation (function) that an OS provides for running applications to use CS 1550 2077 strace./hello

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

Process Management! Goals of this Lecture!

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

Process management. What s in a process? What is a process? The OS s process namespace. A process s address space (idealized)

Process management. What s in a process? What is a process? The OS s process namespace. A process s address space (idealized) Process management CSE 451: Operating Systems Spring 2012 Module 4 Processes Ed Lazowska lazowska@cs.washington.edu Allen Center 570 This module begins a series of topics on processes, threads, and synchronization

More information

CSE 451: Operating Systems Winter Module 4 Processes. Mark Zbikowski Allen Center 476

CSE 451: Operating Systems Winter Module 4 Processes. Mark Zbikowski Allen Center 476 CSE 451: Operating Systems Winter 2015 Module 4 Processes Mark Zbikowski mzbik@cs.washington.edu Allen Center 476 2013 Gribble, Lazowska, Levy, Zahorjan Process management This module begins a series of

More information

System Calls & Signals. CS449 Spring 2016

System Calls & Signals. CS449 Spring 2016 System Calls & Signals CS449 Spring 2016 Operating system OS a layer of software interposed between the application program and the hardware Application programs Operating system Processor Main memory

More information

APPLIED INFORMATICS Processes. Bash characteristics. Command type. Aliases.

APPLIED INFORMATICS Processes. Bash characteristics. Command type. Aliases. Lab 3 APPLIED INFORMATICS Processes. Bash characteristics. Command type. Aliases. Today... /proc /run 1. PROCESSES 2. BASH CHARACTERISTICS 3. COMMAND TYPES 4. ALIASES $$ $PPID pidof ps pgrep kill killall

More information

Process Management 1

Process 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 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

Chapter 4 Multithreaded Programming

Chapter 4 Multithreaded Programming Chapter 4 Multithreaded Programming Da-Wei Chang CSIE.NCKU Source: Abraham Silberschatz, Peter B. Galvin, and Greg Gagne, "Operating System Concepts", 9th Edition, Wiley. 1 1 Outline Overview Multithreading

More information

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF MCA QUESTION BANK UNIT 1

CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF MCA QUESTION BANK UNIT 1 CHETTINAD COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF MCA QUESTION BANK SUBJECT: NETWORK PROGRAMMING/MC9241 YEAR/ SEM: II /I V 1 CCET UNIT 1 1. What are the steps involved in obtaining a shared

More information

Chapter 1 Introduction

Chapter 1 Introduction Chapter 1 Introduction Hsung-Pin Chang Department of Computer Science National Chung Hsing University Preference On the basis of 2.4.18 of the Linux kernel www.kernel.org Linux source code is contained

More information

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

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

More information

CSC 1600 Unix Processes. Goals of This Lecture

CSC 1600 Unix Processes. Goals of This Lecture CSC 1600 Unix Processes q Processes Goals of This Lecture q Process vs. program q Context switching q Creating a new process q fork: process creates a new child process q wait: parent waits for child process

More information

System Programming. Signals I

System Programming. Signals 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 Introduction 2 3 Signals

More information

VALLIAMMAI ENGINEERING COLLEGE. SRM Nagar, Kattankulathur QUESTION BANK

VALLIAMMAI ENGINEERING COLLEGE. SRM Nagar, Kattankulathur QUESTION BANK SRM Nagar, Kattankulathur 603 203 IV SEMESTER MC7404 NETWORK PROGRAMMING Regulation 2013 Academic Year 2017 18 Prepared by Mr. M.Asan Nainar, Assistant Professor/MCA UNIT I - INTRODUCTION Overview of UNIX

More information

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D) MANAGEMENT OF APPLICATION EXECUTION PROCESS CONTROL BLOCK Resources (processor, I/O devices, etc.) are made available to multiple applications The processor in particular is switched among multiple applications

More information

LESSON PLAN. Sub. Code & Name : IT2351 & Network Programming and Management Unit : I Branch: IT Year : III Semester: VI.

LESSON PLAN. Sub. Code & Name : IT2351 & Network Programming and Management Unit : I Branch: IT Year : III Semester: VI. Unit : I Branch: IT Year : III Semester: VI Page: 1 of 6 UNIT I ELEMENTARY TCP SOCKETS 9 Introduction to Socket Programming Overview of TCP/IP Protocols Introduction to Sockets Socket address Structures

More information

Signals. Joseph Cordina

Signals. Joseph Cordina 1 Signals Signals are software interrupts that give us a way to handle asynchronous events. Signals can be received by or sent to any existing process. It provides a flexible way to stop execution of a

More information

Module A: The FreeBSD System

Module A: The FreeBSD System Module A: The FreeBSD System History Design Principles Programmer Interface User Interface Process Management Memory Management File System I/O System Interprocess Communication A.1 History First developed

More information

Module A: The FreeBSD System

Module A: The FreeBSD System Module A: The FreeBSD System History Design Principles Programmer Interface User Interface Process Management Memory Management File System I/O System Interprocess Communication A.1 History First developed

More information

Introduction to UNIX and Linux: Lecture 1

Introduction to UNIX and Linux: Lecture 1 Introduction to UNIX: Lecture One 1.1 Objectives This lecture covers: The concept of an operating system. The internal architecture of an operating system. The evolution of the UNIX operating system into

More information

UNIX Kernel. UNIX History

UNIX Kernel. UNIX History UNIX History UNIX Kernel 1965-1969 Bell Labs participates in the Multics project. 1969 Ken Thomson develops the first UNIX version in assembly for an DEC PDP-7 1973 Dennis Ritchie helps to rewrite UNIX

More information

Advanced Unix Concepts. Satyajit Rai

Advanced Unix Concepts. Satyajit Rai Advanced Unix Concepts Advanced Unix Concepts Satyajit Rai March 17, 2003 March 22, 2003 KReSIT, IIT Bombay 1 Contents Contents Advanced Unix Concepts.......... 1 Contents.................. 2 Process Creation..............

More information

Interprocess Communication

Interprocess Communication Interprocess Communication Reading: Silberschatz chapter 4 Additional Reading: Stallings chapter 6 EEL 358 1 Outline Introduction Shared memory systems POSIX shared memory Message passing systems Direct

More information

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview Today CSCI 4061 Introduction to s Instructor: Abhishek Chandra OS Evolution Unix Overview Unix Structure Shells and Utilities Calls and APIs 2 Evolution How did the OS evolve? Dependent on hardware and

More information

Appendix A: FreeBSD. Operating System Concepts 9 th Edition

Appendix A: FreeBSD. Operating System Concepts 9 th Edition Appendix A: FreeBSD Operating System Concepts 9 th Edition Silberschatz, Galvin and Gagne 2013 Module A: The FreeBSD System UNIX History Design Principles Programmer Interface User Interface Process Management

More information

Operating System Structure

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

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : LINUX PROGRAMMING Course Code : ACS010 Class : III

More information

Preview. Process Termination. wait and waitpid() System Call. wait and waitpid() System Call. waitpid() System Call 10/23/2018

Preview. Process Termination. wait and waitpid() System Call. wait and waitpid() System Call. waitpid() System Call 10/23/2018 Preview Process Termination The waitpid() System Call The system() System Call Concept of Signals Linux Signals The signal System Call Unreliable Signals Signal() System Call The kill() and raise() System

More information

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview

Today. Operating System Evolution. CSCI 4061 Introduction to Operating Systems. Gen 1: Mono-programming ( ) OS Evolution Unix Overview Today CSCI 4061 Introduction to s Instructor: Abhishek Chandra OS Evolution Unix Overview Unix Structure Shells and Utilities Calls and APIs 2 Evolution How did the OS evolve? Generation 1: Mono-programming

More information

St. MARTIN S ENGINEERING COLLEGE Dhulapally,Secunderabad DEPARTMENT OF INFORMATION TECHNOLOGY Academic year

St. MARTIN S ENGINEERING COLLEGE Dhulapally,Secunderabad DEPARTMENT OF INFORMATION TECHNOLOGY Academic year St. MARTIN S ENGINEERING COLLEGE Dhulapally,Secunderabad-000 DEPARTMENT OF INFORMATION TECHNOLOGY Academic year 0-0 QUESTION BANK Course Name : LINUX PROGRAMMING Course Code : A0 Class : III B. Tech I

More information

Memory-Mapped Files. generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length)

Memory-Mapped Files. generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length) File Systems 38 Memory-Mapped Files generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length) mmap call returns the virtual address to which the file is mapped munmap call unmaps

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

shared storage These mechanisms have already been covered. examples: shared virtual memory message based signals

shared storage These mechanisms have already been covered. examples: shared virtual memory message based signals 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

ECE 650 Systems Programming & Engineering. Spring 2018

ECE 650 Systems Programming & Engineering. Spring 2018 ECE 650 Systems Programming & Engineering Spring 2018 User Space / Kernel Interaction Tyler Bletsch Duke University Slides are adapted from Brian Rogers (Duke) Operating System Services User and other

More information

Lecture 4 Threads. (chapter 4)

Lecture 4 Threads. (chapter 4) Bilkent University Department of Computer Engineering CS342 Operating Systems Lecture 4 Threads (chapter 4) Dr. İbrahim Körpeoğlu http://www.cs.bilkent.edu.tr/~korpe 1 References The slides here are adapted/modified

More information

Process Management! Goals of this Lecture!

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

This tutorial covers a foundational understanding of IPC. Each of the chapters contain related topics with simple and useful examples.

This tutorial covers a foundational understanding of IPC. Each of the chapters contain related topics with simple and useful examples. About the Tutorial Inter Process Communication (IPC) refers to a mechanism, where the operating systems allow various processes to communicate with each other. This involves synchronizing their actions

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: 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 information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

CSC209: 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 information

CS240: Programming in C

CS240: 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 information

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems. Copyleft 2005, Binnur Kurt 3 Operating Systems Copyleft 2005, Binnur Kurt Content The concept of an operating system. The internal architecture of an operating system. The architecture of the Linux operating system in more detail.

More information

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing Content 3 Operating Systems The concept of an operating system. The internal architecture of an operating system. The architecture of the Linux operating system in more detail. How to log into (and out

More information

Fall 2015 COMP Operating Systems. Lab #3

Fall 2015 COMP Operating Systems. Lab #3 Fall 2015 COMP 3511 Operating Systems Lab #3 Outline n Operating System Debugging, Generation and System Boot n Review Questions n Process Control n UNIX fork() and Examples on fork() n exec family: execute

More information

Preview. Process Control. What is process? Process identifier The fork() System Call File Sharing Race Condition. COSC350 System Software, Fall

Preview. Process Control. What is process? Process identifier The fork() System Call File Sharing Race Condition. COSC350 System Software, Fall Preview Process Control What is process? Process identifier The fork() System Call File Sharing Race Condition COSC350 System Software, Fall 2015 1 Von Neumann Computer Architecture: An integrated set

More information

EXPERIMENT NO : M/C Lenovo Think center M700 Ci3,6100,6th Gen. H81, 4GB RAM,500GB HDD

EXPERIMENT NO : M/C Lenovo Think center M700 Ci3,6100,6th Gen. H81, 4GB RAM,500GB HDD GROUP - C EXPERIMENT NO : 12 1. Title: Implement UNIX system calls like ps, fork, join, exec family, and wait for process management (use shell script/ Java/ C programming) 2. Objectives : - To understand

More information

Operating Systemss and Multicore Programming (1DT089)

Operating Systemss and Multicore Programming (1DT089) Operating Systemss and Multicore Programming (1DT089) Problem Set 1 - Tutorial January 2013 Uppsala University karl.marklund@it.uu.se pointers.c Programming with pointers The init() functions is similar

More information

CSC209 Fall Karen Reid 1

CSC209 Fall Karen Reid 1 ' & ) ) #$ "! How user programs interact with the Operating System. Somehow we need to convert a program into machine code (object code). A compiler passes over a whole program before translating it into

More information

Parents and Children

Parents and Children 1 Process Identifiers Every process apart from the PID also has a PUID and a PGID. There are two types of PUID and PGID: real and effective. The real PUID is always equal to the user running the process

More information

A process. the stack

A process. the stack A process Processes Johan Montelius What is a process?... a computation KTH 2017 a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other processes

More information

Princeton University. Computer Science 217: Introduction to Programming Systems. Signals

Princeton University. Computer Science 217: Introduction to Programming Systems. Signals Princeton University Computer Science 217: Introduction to Programming Systems Signals 1 Goals of this Lecture Help you learn about: Sending signals Handling signals and thereby How the OS exposes the

More information

Fortran Signal Handling

Fortran Signal Handling Fortran Signal Handling Ge Baolai SHARCNET The University of Western Ontario June 19, 2008 1 Signal Handling in User Applications A running programme may be interrupted or terminated by the operating system.

More information

Operating Systems. Lecture 05

Operating Systems. Lecture 05 Operating Systems Lecture 05 http://web.uettaxila.edu.pk/cms/sp2013/seosbs/ February 25, 2013 Process Scheduling, System Calls Execution (Fork,Wait,Exit,Exec), Inter- Process Communication Schedulers Long

More information

CSC209 Review. Yeah! We made it!

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

PROCESS CONCEPTS. Process Concept Relationship to a Program What is a Process? Process Lifecycle Process Management Inter-Process Communication 2.

PROCESS CONCEPTS. Process Concept Relationship to a Program What is a Process? Process Lifecycle Process Management Inter-Process Communication 2. [03] PROCESSES 1. 1 OUTLINE Process Concept Relationship to a Program What is a Process? Process Lifecycle Creation Termination Blocking Process Management Process Control Blocks Context Switching Threads

More information

Processes. Johan Montelius KTH

Processes. Johan Montelius KTH Processes Johan Montelius KTH 2017 1 / 47 A process What is a process?... a computation a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other

More information

CISC 220 fall 2011, set 1: Linux basics

CISC 220 fall 2011, set 1: Linux basics CISC 220: System-Level Programming instructor: Margaret Lamb e-mail: malamb@cs.queensu.ca office: Goodwin 554 office phone: 533-6059 (internal extension 36059) office hours: Tues/Wed/Thurs 2-3 (this week

More information

CS 355 Operating Systems. Keeping Track of Processes. When are processes created? Process States 1/26/18. Processes, Unix Processes and System Calls

CS 355 Operating Systems. Keeping Track of Processes. When are processes created? Process States 1/26/18. Processes, Unix Processes and System Calls CS 355 Operating Systems Processes, Unix Processes and System Calls Process User types command like run foo at keyboard I/O device driver for keyboard and screen Command is parsed by command shell Executable

More information

Operating System Design

Operating System Design Operating System Design Processes Operations Inter Process Communication (IPC) Neda Nasiriani Fall 2018 1 Process 2 Process Lifecycle 3 What information is needed? If you want to design a scheduler to

More information

Introduction to Processes

Introduction to Processes Computer Systems II Introduction to Processes 1 Review: Basic Computer Hardware CPU Instruction Register Control BUS read (disk) local buffer Disk Controller Memory Executable Disk 1 Review: Timing Problem

More information

Killing Zombies, Working, Sleeping, and Spawning Children

Killing Zombies, Working, Sleeping, and Spawning Children Killing Zombies, Working, Sleeping, and Spawning Children CS 333 Prof. Karavanic (c) 2015 Karen L. Karavanic 1 The Process Model The OS loads program code and starts each job. Then it cleans up afterwards,

More information

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu CPSC 341 OS & Networks Processes Dr. Yingwu Zhu Process Concept Process a program in execution What is not a process? -- program on a disk A process is an active object, but a program is just a file It

More information

Signals. Goals of this Lecture. Help you learn about: Sending signals Handling signals

Signals. Goals of this Lecture. Help you learn about: Sending signals Handling signals Signals 1 Goals of this Lecture Help you learn about: Sending signals Handling signals and thereby How the OS exposes the occurrence of some exceptions to application processes How application processes

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 20

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 20 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2018 Lecture 20 LAST TIME: UNIX PROCESS MODEL Began covering the UNIX process model and API Information associated with each process: A PID (process ID) to

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

Processes & Signals. System Runs Many Processes Concurrently. State consists of memory image + register values + program counter

Processes & Signals. System Runs Many Processes Concurrently. State consists of memory image + register values + program counter Processes & Signals Topics Process Hierarchy Shells Signals The World of Multitasking System Runs Many Processes Concurrently Process: executing program State consists of memory image + register values

More information

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Processes Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu OS Internals User space shell ls trap shell ps Kernel space File System Management I/O

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

Creating a Shell or Command Interperter Program CSCI411 Lab

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

Workshop on Inter Process Communication Solutions

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

Operating Systemss and Multicore Programming (1DT089)

Operating Systemss and Multicore Programming (1DT089) Operating Systemss and Multicore Programming (1DT089) The Process Concept and Inter Processs Communication (Chapter 3) Tuesday january 28 Uppsala University 2014 karl.marklund@it.uu.se 1.5.1) Dual-Mode

More information

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo PROCESS MANAGEMENT Operating Systems 2015 Spring by Euiseong Seo Today s Topics Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication

More information

Appendix A GLOSSARY. SYS-ED/ Computer Education Techniques, Inc.

Appendix A GLOSSARY. SYS-ED/ Computer Education Techniques, Inc. Appendix A GLOSSARY SYS-ED/ Computer Education Techniques, Inc. $# Number of arguments passed to a script. $@ Holds the arguments; unlike $* it has the capability for separating the arguments. $* Holds

More information

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : LINUX PROGRAMMING Course Code : A70511 (R15) Class

More information

Shell and Signals. Computer Organization 3/17/2015. CSC252 - Spring The World of Multiprogramming or Multitasking. Unix Process Hierarchy

Shell and Signals. Computer Organization 3/17/2015. CSC252 - Spring The World of Multiprogramming or Multitasking. Unix Process Hierarchy Shell and Signals Kai Shen The World of Multiprogramming or Multitasking System runs many processes concurrently Process: executing program State includes memory image + register values + program counter

More information

Unix Processes. What is a Process?

Unix Processes. What is a Process? Unix Processes Process -- program in execution shell spawns a process for each command and terminates it when the command completes Many processes all multiplexed to a single processor (or a small number

More information

PROCESSES. Jo, Heeseung

PROCESSES. Jo, Heeseung PROCESSES Jo, Heeseung TODAY'S TOPICS What is the process? How to implement processes? Inter-Process Communication (IPC) 2 WHAT IS THE PROCESS? Program? vs. Process? vs. Processor? 3 PROCESS CONCEPT (1)

More information

Processes. Jo, Heeseung

Processes. Jo, Heeseung Processes Jo, Heeseung Today's Topics What is the process? How to implement processes? Inter-Process Communication (IPC) 2 What Is The Process? Program? vs. Process? vs. Processor? 3 Process Concept (1)

More information

Computer Science 330 Operating Systems Siena College Spring Lab 5: Unix Systems Programming Due: 4:00 PM, Wednesday, February 29, 2012

Computer Science 330 Operating Systems Siena College Spring Lab 5: Unix Systems Programming Due: 4:00 PM, Wednesday, February 29, 2012 Computer Science 330 Operating Systems Siena College Spring 2012 Lab 5: Unix Systems Programming Due: 4:00 PM, Wednesday, February 29, 2012 Quote: UNIX system calls, reading about those can be about as

More information

518 Lecture Notes Week 3

518 Lecture Notes Week 3 518 Lecture Notes Week 3 (Sept. 15, 2014) 1/8 518 Lecture Notes Week 3 1 Topics Process management Process creation with fork() Overlaying an existing process with exec Notes on Lab 3 2 Process management

More information

Practical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015

Practical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015 Practical Computing-II March 20, 2015 0. An Introduction About The Course CMS M.2.2 Practical Computing-II About The Course CMS M.2.2 Practical Computing-II 25 credits (33.33% weighting) About The Course

More information

Chp1 Introduction. Introduction. Objective. Logging In. Shell. Briefly describe services provided by various versions of the UNIX operating system.

Chp1 Introduction. Introduction. Objective. Logging In. Shell. Briefly describe services provided by various versions of the UNIX operating system. Chp1 Objective Briefly describe services provided by various versions of the UNIX operating system. Logging In /etc/passwd local machine or NIS DB root:x:0:1:super-user:/root:/bin/tcsh Login-name, encrypted

More information

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel CIS 657 Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler (2%

More information

Processes & Threads. Today. Next Time. ! Process concept! Process model! Implementing processes! Multiprocessing once again. ! More of the same J

Processes & Threads. Today. Next Time. ! Process concept! Process model! Implementing processes! Multiprocessing once again. ! More of the same J Processes & Threads Today! Process concept! Process model! Implementing processes! Multiprocessing once again Next Time! More of the same J The process model! Most computers can do more than one thing

More information

Linux Operating System

Linux Operating System Linux Operating System Dept. of Computer Science & Engineering 1 History Linux is a modern, free operating system based on UNIX standards. First developed as a small but self-contained kernel in 1991 by

More information

Lesson 3. The func procedure allows a user to choose the action upon receipt of a signal.

Lesson 3. The func procedure allows a user to choose the action upon receipt of a signal. Lesson 3 Signals: When a process terminates abnormally, it usually tries to send a signal indicating what went wrong. C programs can trap these for diagnostics. Software interrupts: Stop executing the

More information

ENGR 3950U / CSCI 3020U Midterm Exam SOLUTIONS, Fall 2012 SOLUTIONS

ENGR 3950U / CSCI 3020U Midterm Exam SOLUTIONS, Fall 2012 SOLUTIONS SOLUTIONS ENGR 3950U / CSCI 3020U (Operating Systems) Midterm Exam October 23, 2012, Duration: 80 Minutes (10 pages, 12 questions, 100 Marks) Instructor: Dr. Kamran Sartipi Question 1 (Computer Systgem)

More information

Process Time. Steven M. Bellovin January 25,

Process Time. Steven M. Bellovin January 25, Multiprogramming Computers don t really run multiple programs simultaneously; it just appears that way Each process runs to completion, but intermixed with other processes Process 1 6 ticks Process 2 Process

More information

CptS 360 (System Programming) Unit 2: Introduction to UNIX and Linux

CptS 360 (System Programming) Unit 2: Introduction to UNIX and Linux CptS 360 (System Programming) Unit 2: Introduction to UNIX and Linux Bob Lewis School of Engineering and Applied Sciences Washington State University Spring, 2018 Motivation APIs have a history: Learn

More information

Maria Hybinette, UGA. ! One easy way to communicate is to use files. ! File descriptors. 3 Maria Hybinette, UGA. ! Simple example: who sort

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

Midterm Exam CPS 210: Operating Systems Spring 2013

Midterm Exam CPS 210: Operating Systems Spring 2013 Your name: Sign for your honor: Midterm Exam CPS 210: Operating Systems Spring 2013 The last page of this exam is a list of terms used in this class, and whose meanings you should know. You may detach

More information

Mon Sep 17, 2007 Lecture 3: Process Management

Mon Sep 17, 2007 Lecture 3: Process Management Mon Sep 17, 2007 Lecture 3: Process Management September 19, 2007 1 Review OS mediates between hardware and user software QUIZ: Q: Name three layers of a computer system where the OS is one of these layers.

More information

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent? Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler

More information

Operating Systems Lab

Operating Systems Lab Operating Systems Lab Islamic University Gaza Engineering Faculty Department of Computer Engineering Fall 2012 ECOM 4010: Operating Systems Lab Eng: Ahmed M. Ayash Lab # 3 Fork() in C and C++ programming

More information

Lecture Topics. Announcements. Today: Operating System Overview (Stallings, chapter , ) Next: Processes (Stallings, chapter

Lecture Topics. Announcements. Today: Operating System Overview (Stallings, chapter , ) Next: Processes (Stallings, chapter Lecture Topics Today: Operating System Overview (Stallings, chapter 2.1-2.4, 2.8-2.10) Next: Processes (Stallings, chapter 3.1-3.6) 1 Announcements Consulting hours posted Self-Study Exercise #3 posted

More information

The Kernel. wants to be your friend

The Kernel. wants to be your friend The Kernel wants to be your friend Boxing them in Buggy apps can crash other apps App 1 App 2 App 3 Operating System Reading and writing memory, managing resources, accessing I/O... Buggy apps can crash

More information

This document gives a general overview of the work done by an operating system and gives specific examples from UNIX.

This document gives a general overview of the work done by an operating system and gives specific examples from UNIX. This document gives a general overview of the work done by an operating system and gives specific examples from UNIX. 1 Manages Resources: I/O devices (disk, keyboard, mouse, terminal) Memory Manages Processes:

More information