Interlude: Process API

Size: px
Start display at page:

Download "Interlude: Process API"

Transcription

1 5 Interlude: Process API ASIDE: INTERLUDES Interludes will cover more practical aspects of systems, including a particular focus on operating system APIs and how to use them. If you don t like practical things, you could skip these interludes. But you should like practical things, because, well, they are generally useful in real life; companies, for example, don t usually hire you for your non-practical skills. In this interlude, we discuss process creation in UNIX systems. UNIX presents one of the most intriguing ways to create a new process with a pair of system calls: fork() and exec(). A third routine, wait(), can be used by a process wishing to wait for a process it has created to complete. We now present these interfaces in more detail, with a few simple examples to motivate us. And thus, our problem: CRUX: HOW TO CREATE AND CONTROL PROCESSES What interfaces should the OS present for process creation and control? How should these interfaces be designed to enable powerful functionality, ease of use, and high performance? 5.1 Thefork() System Call Thefork() system call is used to create a new process [C63]. However, be forewarned: it is certainly the strangest routine you will ever call 1. More specifically, you have a running program whose code looks like what you see in Figure 5.1; examine the code, or better yet, type it in and run it yourself! 1 Well, OK, we admit that we don t know that for sure; who knows what routines you call when no one is looking? Butfork() is pretty odd, no matter how unusual your routinecalling patterns are. 1

2 2 INTERLUDE: PROCESS API 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 5 int main(int argc, char *argv[]) { 6 printf("hello world (pid:%d)\n", (int) getpid()); 7 int rc = fork(); 8 if (rc < 0) { // fork failed; exit 9 fprintf(stderr, "fork failed\n"); 10 exit(1); 11 } else if (rc == 0) { // child (new process) 12 printf("hello, I am child (pid:%d)\n", (int) getpid()); 13 } else { // parent goes down this path (main) 14 printf("hello, I am parent of %d (pid:%d)\n", 15 rc, (int) getpid()); 16 } 17 return 0; 18 } 19 Figure 5.1: Callingfork() (p1.c) When you run this program (calledp1.c), you ll see the following: prompt>./p1 hello world (pid:29146) hello, I am parent of (pid:29146) hello, I am child (pid:29147) prompt> Let us understand what happened in more detail in p1.c. When it first started running, the process prints out a hello world message; included in that message is its process identifier, also known as a PID. The process has a PID of 29146; in UNIX systems, the PID is used to name the process if one wants to do something with the process, such as (for example) stop it from running. So far, so good. Now the interesting part begins. The process calls thefork() system call, which the OS provides as a way to create a new process. The odd part: the process that is created is an (almost) exact copy of the calling process. That means that to the OS, it now looks like there are two copies of the programp1 running, and both are about to return from thefork() system call. The newly-created process (called the child, in contrast to the creating parent) doesn t start running at main(), like you might expect (note, the hello, world message only got printed out once); rather, it just comes into life as if it had calledfork() itself. You might have noticed: the child isn t an exact copy. Specifically, although it now has its own copy of the address space (i.e., its own private memory), its own registers, its own PC, and so forth, the value it returns to the caller of fork() is different. Specifically, while the parent receives the PID of the newly-created child, the child receives a return code of zero. This differentiation is useful, because it is simple then to write the code that handles the two different cases (as above). OPERATING SYSTEMS [VERSION 1.00]

3 INTERLUDE: PROCESS API 3 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 #include <sys/wait.h> 5 6 int main(int argc, char *argv[]) { 7 printf("hello world (pid:%d)\n", (int) getpid()); 8 int rc = fork(); 9 if (rc < 0) { // fork failed; exit 10 fprintf(stderr, "fork failed\n"); 11 exit(1); 12 } else if (rc == 0) { // child (new process) 13 printf("hello, I am child (pid:%d)\n", (int) getpid()); 14 } else { // parent goes down this path (main) 15 int rc_wait = wait(null); 16 printf("hello, I am parent of %d (rc_wait:%d) (pid:%d)\n", 17 rc, rc_wait, (int) getpid()); 18 } 19 return 0; 20 } 21 Figure 5.2: Callingfork() Andwait() (p2.c) You might also have noticed: the output (of p1.c) is not deterministic. When the child process is created, there are now two active processes in the system that we care about: the parent and the child. Assuming we are running on a system with a single CPU (for simplicity), then either the child or the parent might run at that point. In our example (above), the parent did and thus printed out its message first. In other cases, the opposite might happen, as we show in this output trace: prompt>./p1 hello world (pid:29146) hello, I am child (pid:29147) hello, I am parent of (pid:29146) prompt> The CPU scheduler, a topic we ll discuss in great detail soon, determines which process runs at a given moment in time; because the scheduler is complex, we cannot usually make strong assumptions about what it will choose to do, and hence which process will run first. This nondeterminism, as it turns out, leads to some interesting problems, particularly in multi-threaded programs; hence, we ll see a lot more nondeterminism when we study concurrency in the second part of the book. 5.2 Thewait() System Call So far, we haven t done much: just created a child that prints out a message and exits. Sometimes, as it turns out, it is quite useful for a parent to wait for a child process to finish what it has been doing. This task is accomplished with the wait() system call (or its more complete siblingwaitpid()); see Figure 5.2 for details. c , ARPACI-DUSSEAU THREE EASY PIECES

4 4 INTERLUDE: PROCESS API In this example (p2.c), the parent process calls wait() to delay its execution until the child finishes executing. When the child is done, wait() returns to the parent. Adding await() call to the code above makes the output deterministic. Can you see why? Go ahead, think about it. (waiting for you to think... and done) Now that you have thought a bit, here is the output: prompt>./p2 hello world (pid:29266) hello, I am child (pid:29267) hello, I am parent of (rc_wait:29267) (pid:29266) prompt> With this code, we now know that the child will always print first. Why do we know that? Well, it might simply run first, as before, and thus print before the parent. However, if the parent does happen to run first, it will immediately call wait(); this system call won t return until the child has run and exited 2. Thus, even when the parent runs first, it politely waits for the child to finish running, then wait() returns, and then the parent prints its message. 5.3 Finally, Theexec() System Call A final and important piece of the process creation API is theexec() system call 3. This system call is useful when you want to run a program that is different from the calling program. For example, calling fork() in p2.c is only useful if you want to keep running copies of the same program. However, often you want to run a different program; exec() does just that (Figure 5.3, page 5). In this example, the child process callsexecvp() in order to run the programwc, which is the word counting program. In fact, it runswc on the source filep3.c, thus telling us how many lines, words, and bytes are found in the file: prompt>./p3 hello world (pid:29383) hello, I am child (pid:29384) p3.c hello, I am parent of (rc_wait:29384) (pid:29383) prompt> 2 There are a few cases where wait() returns before the child exits; read the man page for more details, as always. And beware of any absolute and unqualified statements this book makes, such as the child will always print first or UNIX is the best thing in the world, even better than ice cream. 3 On Linux, there are six variants of exec(): execl, execlp(), execle(), execv(), execvp(), andexecvpe(). Read the man pages to learn more. OPERATING SYSTEMS [VERSION 1.00]

5 INTERLUDE: PROCESS API 5 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 #include <string.h> 5 #include <sys/wait.h> 6 7 int main(int argc, char *argv[]) { 8 printf("hello world (pid:%d)\n", (int) getpid()); 9 int rc = fork(); 10 if (rc < 0) { // fork failed; exit 11 fprintf(stderr, "fork failed\n"); 12 exit(1); 13 } else if (rc == 0) { // child (new process) 14 printf("hello, I am child (pid:%d)\n", (int) getpid()); 15 char *myargs[3]; 16 myargs[0] = strdup("wc"); // program: "wc" (word count) 17 myargs[1] = strdup("p3.c"); // argument: file to count 18 myargs[2] = NULL; // marks end of array 19 execvp(myargs[0], myargs); // runs word count 20 printf("this shouldn t print out"); 21 } else { // parent goes down this path (main) 22 int rc_wait = wait(null); 23 printf("hello, I am parent of %d (rc_wait:%d) (pid:%d)\n", 24 rc, rc_wait, (int) getpid()); 25 } 26 return 0; 27 } 28 Figure 5.3: Callingfork(),wait(), Andexec() (p3.c) Thefork() system call is strange; its partner in crime,exec(), is not so normal either. What it does: given the name of an executable (e.g.,wc), and some arguments (e.g., p3.c), it loads code (and static data) from that executable and overwrites its current code segment (and current static data) with it; the heap and stack and other parts of the memory space of the program are re-initialized. Then the OS simply runs that program, passing in any arguments as the argv of that process. Thus, it does not create a new process; rather, it transforms the currently running program (formerly p3) into a different running program (wc). After the exec() in the child, it is almost as ifp3.c never ran; a successful call toexec() never returns. 5.4 Why? Motivating The API Of course, one big question you might have: why would we build such an odd interface to what should be the simple act of creating a new process? Well, as it turns out, the separation of fork() and exec() is essential in building a UNIX shell, because it lets the shell run code after the call to fork() but before the call to exec(); this code can alter the environment of the about-to-be-run program, and thus enables a variety of interesting features to be readily built. c , ARPACI-DUSSEAU THREE EASY PIECES

6 6 INTERLUDE: PROCESS API TIP: GETTING IT RIGHT (LAMPSON S LAW) As Lampson states in his well-regarded Hints for Computer Systems Design [L83], Get it right. Neither abstraction nor simplicity is a substitute for getting it right. Sometimes, you just have to do the right thing, and when you do, it is way better than the alternatives. There are lots of ways to design APIs for process creation; however, the combination of fork() and exec() are simple and immensely powerful. Here, the UNIX designers simply got it right. And because Lampson so often got it right, we name the law in his honor. The shell is just a user program 4. It shows you a prompt and then waits for you to type something into it. You then type a command (i.e., the name of an executable program, plus any arguments) into it; in most cases, the shell then figures out where in the file system the executable resides, callsfork() to create a new child process to run the command, calls some variant ofexec() to run the command, and then waits for the command to complete by callingwait(). When the child completes, the shell returns fromwait() and prints out a prompt again, ready for your next command. The separation offork() andexec() allows the shell to do a whole bunch of useful things rather easily. For example: prompt> wc p3.c > newfile.txt In the example above, the output of the programwc is redirected into the output file newfile.txt (the greater-than sign is how said redirection is indicated). The way the shell accomplishes this task is quite simple: when the child is created, before calling exec(), the shell closes standard output and opens the filenewfile.txt. By doing so, any output from the soon-to-be-running program wc are sent to the file instead of the screen. Figure 5.4 (page 7) shows a program that does exactly this. The reason this redirection works is due to an assumption about how the operating system manages file descriptors. Specifically, UNIX systems start looking for free file descriptors at zero. In this case, STDOUT FILENO will be the first available one and thus get assigned when open() is called. Subsequent writes by the child process to the standard output file descriptor, for example by routines such asprintf(), will then be routed transparently to the newly-opened file instead of the screen. Here is the output of running thep4.c program: prompt>./p4 prompt> cat p4.output p4.c prompt> 4 And there are lots of shells; tcsh, bash, andzsh to name a few. You should pick one, read its man pages, and learn more about it; all UNIX experts do. OPERATING SYSTEMS [VERSION 1.00]

7 INTERLUDE: PROCESS API 7 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <unistd.h> 4 #include <string.h> 5 #include <fcntl.h> 6 #include <sys/wait.h> 7 8 int main(int argc, char *argv[]) { 9 int rc = fork(); 10 if (rc < 0) { // fork failed; exit 11 fprintf(stderr, "fork failed\n"); 12 exit(1); 13 } else if (rc == 0) { // child: redirect standard output to a file 14 close(stdout_fileno); 15 open("./p4.output", O_CREAT O_WRONLY O_TRUNC, S_IRWXU); // now exec "wc" char *myargs[3]; 19 myargs[0] = strdup("wc"); // program: "wc" (word count) 20 myargs[1] = strdup("p4.c"); // argument: file to count 21 myargs[2] = NULL; // marks end of array 22 execvp(myargs[0], myargs); // runs word count 23 } else { // parent goes down this path (main) 24 int rc_wait = wait(null); 25 } 26 return 0; 27 } Figure 5.4: All Of The Above With Redirection (p4.c) You ll notice (at least) two interesting tidbits about this output. First, whenp4 is run, it looks as if nothing has happened; the shell just prints the command prompt and is immediately ready for your next command. However, that is not the case; the programp4 did indeed callfork() to create a new child, and then run thewc program via a call toexecvp(). You don t see any output printed to the screen because it has been redirected to the filep4.output. Second, you can see that when wecat the output file, all the expected output from running wc is found. Cool, right? UNIX pipes are implemented in a similar way, but with the pipe() system call. In this case, the output of one process is connected to an inkernel pipe (i.e., queue), and the input of another process is connected to that same pipe; thus, the output of one process seamlessly is used as input to the next, and long and useful chains of commands can be strung together. As a simple example, consider looking for a word in a file, and then counting how many times said word occurs; with pipes and the utilitiesgrep andwc, it is easy just typegrep -o foo file wc -l into the command prompt and marvel at the result. Finally, while we just have sketched out the process API at a high level, there is a lot more detail about these calls out there to be learned and digested; we ll learn more, for example, about file descriptors when we talk about file systems in the third part of the book. For now, suffice it to say that thefork()/exec() combination is a powerful way to create and manipulate processes. c , ARPACI-DUSSEAU THREE EASY PIECES

8 8 INTERLUDE: PROCESS API ASIDE: RTFM READ THE MAN PAGES Many times in this book, when referring to a particular system call or library call, we ll tell you to read the manual pages, or man pages for short. Man pages are the original form of documentation that exist on UNIX systems; realize that they were created before the thing called the web existed. Spending some time reading man pages is a key step in the growth of a systems programmer; there are tons of useful tidbits hidden in those pages. Some particularly useful pages to read are the man pages for whichever shell you are using (e.g., tcsh, or bash), and certainly for any system calls your program makes (in order to see what return values and error conditions exist). Finally, reading the man pages can save you some embarrassment. When you ask colleagues about some intricacy of fork(), they may simply reply: RTFM. This is your colleagues way of gently urging you to Read The Man pages. The F in RTFM just adds a little color to the phrase Process Control And Users Beyondfork(), exec(), andwait(), there are a lot of other interfaces for interacting with processes in UNIX systems. For example, the kill() system call is used to send signals to a process, including directives to pause, die, and other useful imperatives. For convenience, in most UNIX shells, certain keystroke combinations are configured to deliver a specific signal to the currently running process; for example, control-c sends a SIGINT (interrupt) to the process (normally terminating it) and control-z sends a SIGTSTP (stop) signal thus pausing the process in mid-execution (you can resume it later with a command, e.g., the fg built-in command found in many shells). The entire signals subsystem provides a rich infrastructure to deliver external events to processes, including ways to receive and process those signals within individual processes, and ways to send signals to individual processes as well as entire process groups. To use this form of communication, a process should use the signal() system call to catch various signals; doing so ensures that when a particular signal is delivered to a process, it will suspend its normal execution and run a particular piece of code in response to the signal. Read elsewhere [SR05] to learn more about signals and their many intricacies. This naturally raises the question: who can send a signal to a process, and who cannot? Generally, the systems we use can have multiple people using them at the same time; if one of these people can arbitrarily send signals such as SIGINT (to interrupt a process, likely terminating it), the usability and security of the system will be compromised. As a result, modern systems include a strong conception of the notion of a user. The user, after entering a password to establish credentials, logs in to gain access to system resources. The user may then launch one or many pro- OPERATING SYSTEMS [VERSION 1.00]

9 INTERLUDE: PROCESS API 9 ASIDE: THE SUPERUSER (ROOT) A system generally needs a user who can administer the system, and is not limited in the way most users are. Such a user should be able to kill an arbitrary process (e.g., if it is abusing the system in some way), even though that process was not started by this user. Such a user should also be able to run powerful commands such as shutdown (which, unsurprisingly, shuts down the system). In UNIX-based systems, these special abilities are given to the superuser (sometimes called root). While most users can t kill other users processes, the superuser can. Being root is much like being Spider-Man: with great power comes great responsibility [QI15]. Thus, to increase security (and avoid costly mistakes), it s usually better to be a regular user; if you do need to be root, tread carefully, as all of the destructive powers of the computing world are now at your fingertips. cesses, and exercise full control over them (pause them, kill them, etc.). Users generally can only control their own processes; it is the job of the operating system to parcel out resources (such as CPU, memory, and disk) to each user (and their processes) to meet overall system goals. 5.6 Useful Tools There are many command-line tools that are useful as well. For example, using the ps command allows you to see which processes are running; read the man pages for some useful flags to pass tops. The tooltop is also quite helpful, as it displays the processes of the system and how much CPU and other resources they are eating up. Humorously, many times when you run it,top claims it is the top resource hog; perhaps it is a bit of an egomaniac. The commandkill can be used to send arbitrary signals to processes, as can the slightly more user friendly killall. Be sure to use these carefully; if you accidentally kill your window manager, the computer you are sitting in front of may become quite difficult to use. Finally, there are many different kinds of CPU meters you can use to get a quick glance understanding of the load on your system; for example, we always keep MenuMeters (from Raging Menace software) running on our Macintosh toolbars, so we can see how much CPU is being utilized at any moment in time. In general, the more information about what is going on, the better. 5.7 Summary We have introduced some of the APIs dealing with UNIX process creation: fork(), exec(), and wait(). However, we have just skimmed the surface. For more detail, read Stevens and Rago [SR05], of course, particularly the chapters on Process Control, Process Relationships, and Signals. There is much to extract from the wisdom therein. c , ARPACI-DUSSEAU THREE EASY PIECES

10 10 INTERLUDE: PROCESS API ASIDE: KEY PROCESS API TERMS Each process has a name; in most systems, that name is a number known as a process ID (PID). The fork() system call is used in UNIX systems to create a new process. The creator is called the parent; the newly created process is called the child. As sometimes occurs in real life [J16], the child process is a nearly identical copy of the parent. The wait() system call allows a parent to wait for its child to complete execution. The exec() family of system calls allows a child to break free from its similarity to its parent and execute an entirely new program. A UNIX shell commonly uses fork(), wait(), and exec() to launch user commands; the separation of fork and exec enables features like input/output redirection, pipes, and other cool features, all without changing anything about the programs being run. Process control is available in the form of signals, which can cause jobs to stop, continue, or even terminate. Which processes can be controlled by a particular person is encapsulated in the notion of a user; the operating system allows multiple users onto the system, and ensures users can only control their own processes. A superuser can control all processes (and indeed do many other things); this role should be assumed infrequently and with caution for security reasons. OPERATING SYSTEMS [VERSION 1.00]

11 INTERLUDE: PROCESS API 11 References [C63] A Multiprocessor System Design by Melvin E. Conway. AFIPS 63 Fall Joint Computer Conference. New York, USA 1963 An early paper on how to design multiprocessing systems; may be the first place the termfork() was used in the discussion of spawning new processes. [DV66] Programming Semantics for Multiprogrammed Computations by Jack B. Dennis and Earl C. Van Horn. Communications of the ACM, Volume 9, Number 3, March A classic paper that outlines the basics of multiprogrammed computer systems. Undoubtedly had great influence on Project MAC, Multics, and eventually UNIX. [J16] They could be twins! by Phoebe Jackson-Edwards. The Daily Mail. March 1, Available: This hard-hitting piece of journalism shows a bunch of weirdly similar child/parent photos and is frankly kind of mesmerizing. Go ahead, waste two minutes of your life and check it out. But don t forget to come back here! This, in a microcosm, is the danger of surfing the web. [L83] Hints for Computer Systems Design by Butler Lampson. ACM Operating Systems Review, Volume 15:5, October Lampson s famous hints on how to design computer systems. You should read it at some point in your life, and probably at many points in your life. [QI15] With Great Power Comes Great Responsibility by The Quote Investigator. Available: The quote investigator concludes that the earliest mention of this concept is 1793, in a collection of decrees made at the French National Convention. The specific quote: Ils doivent envisager qu une grande responsabilit est la suite insparable d un grand pouvoir, which roughly translates to They must consider that great responsibility follows inseparably from great power. Only in 1962 did the following words appear in Spider-Man:...with great power there must also come great responsibility! So it looks like the French Revolution gets credit for this one, not Stan Lee. Sorry, Stan. [SR05] Advanced Programming in the UNIX Environment by W. Richard Stevens, Stephen A. Rago. Addison-Wesley, All nuances and subtleties of using UNIX APIs are found herein. Buy this book! Read it! And most importantly, live it. c , ARPACI-DUSSEAU THREE EASY PIECES

12 12 INTERLUDE: PROCESS API ASIDE: CODING HOMEWORKS Coding homeworks are small exercises where you write code to run on a real machine to get some experience with some basic operating system APIs. After all, you are (probably) a computer scientist, and therefore should like to code, right? (if you don t, there is always CS theory, but that s pretty hard) Of course, to truly become an expert, you have to spend more than a little time hacking away at the machine; indeed, find every excuse you can to write some code and see how it works. Spend the time, and become the wise master you know you can be. Homework (Code) In this homework, you are to gain some familiarity with the process management APIs about which you just read. Don t worry it s even more fun than it sounds! You ll in general be much better off if you find as much time as you can to write some code, so why not start now? Questions 1. Write a program that calls fork(). Before calling fork(), have the main process access a variable (e.g., x) and set its value to something (e.g., 100). What value is the variable in the child process? What happens to the variable when both the child and parent change the value ofx? 2. Write a program that opens a file (with the open() system call) and then calls fork() to create a new process. Can both the child and parent access the file descriptor returned by open()? What happens when they are writing to the file concurrently, i.e., at the same time? 3. Write another program using fork(). The child process should print hello ; the parent process should print goodbye. You should try to ensure that the child process always prints first; can you do this without calling wait() in the parent? 4. Write a program that callsfork() and then calls some form ofexec() to run the program/bin/ls. See if you can try all of the variants ofexec(), including (on Linux)execl(), execle(), execlp(), execv(), execvp(), andexecvpe(). Why do you think there are so many variants of the same basic call? 5. Now write a program that useswait() to wait for the child process to finish in the parent. What does wait() return? What happens if you use wait() in the child? 6. Write a slight modification of the previous program, this time using waitpid() instead ofwait(). When wouldwaitpid() be useful? 7. Write a program that creates a child process, and then in the child closes standard output (STDOUT FILENO). What happens if the child calls printf() to print some output after closing the descriptor? 8. Write a program that creates two children, and connects the standard output of one to the standard input of the other, using thepipe() system call. OPERATING SYSTEMS [VERSION 1.00]

API Interlude: Process Creation (DRAFT)

API Interlude: Process Creation (DRAFT) 5 API Interlude: Process Creation (DRAFT) In this interlude, we discuss process creation in UNIX systems. UNIX presents one of the most intriguing ways to create a new process with a pair of system calls:

More information

The Process Abstraction. CMPU 334 Operating Systems Jason Waterman

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

TCSS 422: OPERATING SYSTEMS

TCSS 422: OPERATING SYSTEMS TCSS 422: OPERATING SYSTEMS fork() Process API, Limited Direct Execution Wes J. Lloyd Institute of Technology University of Washington - Tacoma Creates a new process - think of a fork in the road Parent

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

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

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

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

Operating systems and concurrency - B03

Operating systems and concurrency - B03 Operating systems and concurrency - B03 David Kendall Northumbria University David Kendall (Northumbria University) Operating systems and concurrency - B03 1 / 15 Introduction This lecture gives a more

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

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

Princeton University Computer Science 217: Introduction to Programming Systems. Process Management

Princeton University Computer Science 217: Introduction to Programming Systems. Process Management Princeton University Computer Science 217: Introduction to Programming Systems Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate

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

Princeton University. Computer Science 217: Introduction to Programming Systems. Process Management

Princeton University. Computer Science 217: Introduction to Programming Systems. Process Management Princeton University Computer Science 217: Introduction to Programming Systems Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate

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

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

Princeton University Computer Science 217: Introduction to Programming Systems. Process Management

Princeton University Computer Science 217: Introduction to Programming Systems. Process Management Princeton University Computer Science 217: Introduction to Programming Systems Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate

More information

Week 2 Intro to the Shell with Fork, Exec, Wait. Sarah Diesburg Operating Systems CS 3430

Week 2 Intro to the Shell with Fork, Exec, Wait. Sarah Diesburg Operating Systems CS 3430 Week 2 Intro to the Shell with Fork, Exec, Wait Sarah Diesburg Operating Systems CS 3430 1 Why is the Shell Important? Shells provide us with a way to interact with the core system Executes programs on

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

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

Unix-Linux 2. Unix is supposed to leave room in the process table for a superuser process that could be used to kill errant processes.

Unix-Linux 2. Unix is supposed to leave room in the process table for a superuser process that could be used to kill errant processes. Unix-Linux 2 fork( ) system call is successful parent suspended child created fork( ) returns child pid to parent fork( ) returns zero value to child; zero is the pid of the swapper/scheduler process both

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

CSci 4061 Introduction to Operating Systems. Processes in C/Unix

CSci 4061 Introduction to Operating Systems. Processes in C/Unix CSci 4061 Introduction to Operating Systems Processes in C/Unix Process as Abstraction Talked about C programs a bit Program is a static entity Process is an abstraction of a running program provided by

More information

Operating System Labs. Yuanbin Wu

Operating System Labs. Yuanbin Wu Operating System Labs Yuanbin Wu cs@ecnu Anouncement Project 1 due 21:00 Oct. 4th FTP In campus: direct connection Out of campus: VPN Windows: cmd \\222.204.249.4:5010 Linux: ftp 222.204.249.4 5010 Operating

More information

Section 2: Processes

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

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

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

More information

Process Management 1

Process Management 1 Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate Executing new programs Shell structure Why? Creating new processes and executing

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

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

Project 2: Shell with History1

Project 2: Shell with History1 Project 2: Shell with History1 See course webpage for due date. Submit deliverables to CourSys: https://courses.cs.sfu.ca/ Late penalty is 10% per calendar day (each 0 to 24 hour period past due). Maximum

More information

What Is A Process? Process States. Process Concept. Process Control Block (PCB) Process State Transition Diagram 9/6/2013. Process Fundamentals

What Is A Process? Process States. Process Concept. Process Control Block (PCB) Process State Transition Diagram 9/6/2013. Process Fundamentals What Is A Process? A process is a program in execution. Process Fundamentals #include int main(int argc, char*argv[]) { int v; printf( hello world\n ); scanf( %d, &v); return 0; Program test

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

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

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1 Reading Assignment 4 Chapter 4 Threads, due 2/7 1/31/13 CSE325 - Processes 1 What s Next? 1. Process Concept 2. Process Manager Responsibilities 3. Operations on Processes 4. Process Scheduling 5. Cooperating

More information

fork System-Level Function

fork System-Level Function Princeton University Computer Science 217: Introduction to Programming Systems Process Management Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate Executing

More information

CS 4410, Fall 2017 Project 1: My First Shell Assigned: August 27, 2017 Due: Monday, September 11:59PM

CS 4410, Fall 2017 Project 1: My First Shell Assigned: August 27, 2017 Due: Monday, September 11:59PM CS 4410, Fall 2017 Project 1: My First Shell Assigned: August 27, 2017 Due: Monday, September 11th @ 11:59PM Introduction The purpose of this assignment is to become more familiar with the concepts of

More information

The Abstraction: The Process

The Abstraction: The Process 4 The Abstraction: The Process In this chapter, we discuss one of the most fundamental abstractions that the OS provides to users: the process. The definition of a process, informally, is quite simple:

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

Computer Systems Assignment 2: Fork and Threads Package

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

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

CS 261 Fall Mike Lam, Professor. Processes

CS 261 Fall Mike Lam, Professor. Processes CS 261 Fall 2016 Mike Lam, Professor Processes Processes Process: instance of an executing program Independent single logical flow and private virtual address space Logical flow: sequence of executed instructions

More information

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

Part I Introduction General Information

Part I Introduction General Information Part I Introduction General Information Fall 2018 It takes a really bad school to ruin a good student and a really fantastic school to rescue a bad student. 1 Dennis J. Frailey Concurrent vs. Parallel:

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

Processes. Operating System CS 217. Supports virtual machines. Provides services: User Process. User Process. OS Kernel. Hardware

Processes. Operating System CS 217. Supports virtual machines. Provides services: User Process. User Process. OS Kernel. Hardware es CS 217 Operating System Supports virtual machines Promises each process the illusion of having whole machine to itself Provides services: Protection Scheduling Memory management File systems Synchronization

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

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

Lab 4. Out: Friday, February 25th, 2005

Lab 4. Out: Friday, February 25th, 2005 CS034 Intro to Systems Programming Doeppner & Van Hentenryck Lab 4 Out: Friday, February 25th, 2005 What you ll learn. In this lab, you ll learn to use function pointers in a variety of applications. You

More information

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

CSC209H Lecture 6. Dan Zingaro. February 11, 2015

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

Pipelines, Forks, and Shell

Pipelines, Forks, and Shell Scribe Notes for CS61: 11/14/13 By David Becerra and Arvind Narayanan Pipelines, Forks, and Shell Anecdote on Pipelines: Anecdote 1: In 1964, Bell Labs manager Doug Mcllroy sent a memo stating that programs

More information

What is a Process? Processes and Process Management Details for running a program

What is a Process? Processes and Process Management Details for running a program 1 What is a Process? Program to Process OS Structure, Processes & Process Management Don Porter Portions courtesy Emmett Witchel! A process is a program during execution. Ø Program = static file (image)

More information

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017 ECE 550D Fundamentals of Computer Systems and Engineering Fall 2017 The Operating System (OS) Prof. John Board Duke University Slides are derived from work by Profs. Tyler Bletsch and Andrew Hilton (Duke)

More information

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

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

More information

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

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

Lecture 3 Process API in UNIX systems

Lecture 3 Process API in UNIX systems Lecture 3 Process API in UNIX systems Contents In this lecture, you will learn some process creation API, including: How to Create Wait for Execute A process, and Why in such the way. The fork() System

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

OS Structure, Processes & Process Management. Don Porter Portions courtesy Emmett Witchel

OS Structure, Processes & Process Management. Don Porter Portions courtesy Emmett Witchel OS Structure, Processes & Process Management Don Porter Portions courtesy Emmett Witchel 1 What is a Process?! A process is a program during execution. Ø Program = static file (image) Ø Process = executing

More information

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song CSCE 313 Introduction to Computer Systems Instructor: Dezhen Song Programs, Processes, and Threads Programs and Processes Threads Programs, Processes, and Threads Programs and Processes Threads Processes

More information

CSCE 313: Intro to Computer Systems

CSCE 313: Intro to Computer Systems CSCE 313 Introduction to Computer Systems Instructor: Dr. Guofei Gu http://courses.cse.tamu.edu/guofei/csce313/ Programs, Processes, and Threads Programs and Processes Threads 1 Programs, Processes, and

More information

Processes. CS3026 Operating Systems Lecture 05

Processes. CS3026 Operating Systems Lecture 05 Processes CS3026 Operating Systems Lecture 05 Dispatcher Admit Ready Queue Dispatch Processor Release Timeout or Yield Event Occurs Blocked Queue Event Wait Implementation: Using one Ready and one Blocked

More information

CSE 153 Design of Operating Systems Fall 2018

CSE 153 Design of Operating Systems Fall 2018 CSE 153 Design of Operating Systems Fall 2018 Lecture 4: Processes (2) Threads Process Creation: Unix In Unix, processes are created using fork() int fork() fork() Creates and initializes a new PCB Creates

More information

Notice: This set of slides is based on the notes by Professor Perrone of Bucknell and the textbook authors Silberschatz, Galvin, and Gagne

Notice: This set of slides is based on the notes by Professor Perrone of Bucknell and the textbook authors Silberschatz, Galvin, and Gagne Process Fundamentals Notice: This set of slides is based on the notes by Professor Perrone of Bucknell and the textbook authors Silberschatz, Galvin, and Gagne CSCI 315 Operating Systems Design 1 What

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

CPS 310 first midterm exam, 10/6/2014

CPS 310 first midterm exam, 10/6/2014 CPS 310 first midterm exam, 10/6/2014 Your name please: Part 1. More fun with fork and exec* What is the output generated by this program? Please assume that each executed print statement completes, e.g.,

More information

Memory Management. To do. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory

Memory Management. To do. q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory Memory Management To do q Basic memory management q Swapping q Kernel memory allocation q Next Time: Virtual memory Memory management Ideal memory for a programmer large, fast, nonvolatile and cheap not

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 19

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 19 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2017 Lecture 19 LAST TIME Introduced UNIX signals A kernel facility that provides user-mode exceptional control flow Allows many hardware-level exceptions

More information

Part II Processes and Threads Process Basics

Part II Processes and Threads Process Basics Part II Processes and Threads Process Basics Fall 2017 Program testing can be used to show the presence of bugs, but never to show their absence 1 Edsger W. Dijkstra From Compilation to Execution A compiler

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

CS 31: Intro to Systems Processes. Kevin Webb Swarthmore College March 31, 2016

CS 31: Intro to Systems Processes. Kevin Webb Swarthmore College March 31, 2016 CS 31: Intro to Systems Processes Kevin Webb Swarthmore College March 31, 2016 Reading Quiz Anatomy of a Process Abstraction of a running program a dynamic program in execution OS keeps track of process

More information

CS 201. Processes. Gerson Robboy Portland State University

CS 201. Processes. Gerson Robboy Portland State University CS 201 Processes Gerson Robboy Portland State University Review Definition: A process is an instance of a running program. One of the most fundamental concepts in computer science. Not the same as program

More information

CITS2002 Systems Programming. Creating a new process using fork() 1 next CITS2002 CITS2002 schedule

CITS2002 Systems Programming. Creating a new process using fork() 1 next CITS2002 CITS2002 schedule 1 next CITS2002 CITS2002 schedule Creating a new process using fork() fork() is very unusual because it returns different values in the (existing) parent process, and the (new) child process: the value

More information

628 Lecture Notes Week 4

628 Lecture Notes Week 4 628 Lecture Notes Week 4 (February 3, 2016) 1/8 628 Lecture Notes Week 4 1 Topics I/O Redirection Notes on Lab 4 Introduction to Threads Review Memory spaces #include #include int

More information

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

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

More information

CS 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

CS61 Scribe Notes Date: Topic: Fork, Advanced Virtual Memory. Scribes: Mitchel Cole Emily Lawton Jefferson Lee Wentao Xu

CS61 Scribe Notes Date: Topic: Fork, Advanced Virtual Memory. Scribes: Mitchel Cole Emily Lawton Jefferson Lee Wentao Xu CS61 Scribe Notes Date: 11.6.14 Topic: Fork, Advanced Virtual Memory Scribes: Mitchel Cole Emily Lawton Jefferson Lee Wentao Xu Administrivia: Final likely less of a time constraint What can we do during

More information

2 Processes. 2 Processes. 2 Processes. 2.1 The Process Model. 2.1 The Process Model PROCESSES OPERATING SYSTEMS

2 Processes. 2 Processes. 2 Processes. 2.1 The Process Model. 2.1 The Process Model PROCESSES OPERATING SYSTEMS OPERATING SYSTEMS PROCESSES 2 All modern computers often do several things at the same time. A modern operating system sees each software as a process. When a user PC is booted, many processes are secretly

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

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

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

(In columns, of course.)

(In columns, of course.) CPS 310 first midterm exam, 10/9/2013 Your name please: Part 1. Fun with forks (a) What is the output generated by this program? In fact the output is not uniquely defined, i.e., it is not always the same.

More information

CS 550 Operating Systems Spring Process II

CS 550 Operating Systems Spring Process II CS 550 Operating Systems Spring 2018 Process II 1 Recap: Process Informal definition: A process is a program in execution. Process is not the same as a program. Program is a passive entity stored in the

More information

CS510 Operating System Foundations. Jonathan Walpole

CS510 Operating System Foundations. Jonathan Walpole CS510 Operating System Foundations Jonathan Walpole The Process Concept 2 The Process Concept Process a program in execution Program - description of how to perform an activity instructions and static

More information

COE518 Lecture Notes Week 4 (Sept. 26, 2011)

COE518 Lecture Notes Week 4 (Sept. 26, 2011) coe518 (Operating Systems) Lecture Notes: Week 4 Page 1 of 11 COE518 Lecture Notes Week 4 (Sept. 26, 2011) Topics Why fork(), then exec()? The delta list structure Alternative approach to Lab 2 More on

More information

Systems Programming/ C and UNIX

Systems Programming/ C and UNIX Systems Programming/ C and UNIX Alice E. Fischer Lecture 6: Processes October 9, 2017 Alice E. FischerLecture 6: Processes Lecture 5: Processes... 1/26 October 9, 2017 1 / 26 Outline 1 Processes 2 Process

More information

CS354 gdb Tutorial Written by Chris Feilbach

CS354 gdb Tutorial Written by Chris Feilbach CS354 gdb Tutorial Written by Chris Feilbach Purpose This tutorial aims to show you the basics of using gdb to debug C programs. gdb is the GNU debugger, and is provided on systems that

More information

Assignment 1. Teaching Assistant: Michalis Pachilakis (

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

Operating Systems. Spring Dongkun Shin, SKKU

Operating Systems. Spring Dongkun Shin, SKKU Operating Systems Spring 2019 1 Syllabus Instructors: Dongkun Shin Office : Room 85470 E-mail : dongkun@skku.edu Office Hours: Tue. 15:00-17:30 or by appointment Lecture notes nyx.skku.ac.kr Courses Operation

More information

Embedded Systems Dr. Santanu Chaudhury Department of Electrical Engineering Indian Institute of Technology, Delhi

Embedded Systems Dr. Santanu Chaudhury Department of Electrical Engineering Indian Institute of Technology, Delhi Embedded Systems Dr. Santanu Chaudhury Department of Electrical Engineering Indian Institute of Technology, Delhi Lecture - 13 Virtual memory and memory management unit In the last class, we had discussed

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture a Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ? Notes: TA office hours on the web PA1

More information

Process a program in execution; process execution must progress in sequential fashion. Operating Systems

Process a program in execution; process execution must progress in sequential fashion. Operating Systems Process Concept An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks 1 Textbook uses the terms job and process almost interchangeably Process

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

Processes. CS439: Principles of Computer Systems January 24, 2018

Processes. CS439: Principles of Computer Systems January 24, 2018 Processes CS439: Principles of Computer Systems January 24, 2018 Last Time History Lesson Hardware expensive, humans cheap Hardware cheap, humans expensive Hardware very cheap, humans very expensive Dual-mode

More information

Project 1: Implementing a Shell

Project 1: Implementing a Shell Assigned: August 28, 2015, 12:20am Due: September 21, 2015, 11:59:59pm Project 1: Implementing a Shell Purpose The purpose of this project is to familiarize you with the mechanics of process control through

More information

CSI Module 2: Processes

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

CS 261 Fall Mike Lam, Professor. Exceptional Control Flow and Processes

CS 261 Fall Mike Lam, Professor. Exceptional Control Flow and Processes CS 261 Fall 2017 Mike Lam, Professor Exceptional Control Flow and Processes Exceptional control flow Most control flow is sequential However, we have seen violations of this rule Exceptional control flow

More information

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes CSci 4061 Introduction to Operating Systems IPC: Basics, Pipes Today Directory wrap-up Communication/IPC Test in one week Communication Abstraction: conduit for data exchange between two or more processes

More information

Chap 4, 5: Process. Dongkun Shin, SKKU

Chap 4, 5: Process. Dongkun Shin, SKKU Chap 4, 5: Process 1 Process Concept Job A bundle of program and data to be executed An entity before submission for execution Process (= running program) An entity that is registered to kernel for execution

More information