Laboratory work in TDDI04 Pintos Assignments 2, 3

Size: px
Start display at page:

Download "Laboratory work in TDDI04 Pintos Assignments 2, 3"

Transcription

1 Laboratory work in TDDI04 Pintos Assignments 2, 3 Viacheslav Izosimov viaiz@ida.liu.se Instead of Motivation The deadline for Lab 1 is extended to 1st of February! KERNEL PANIC!!! YOUR PINTOS IMPLEMENATION IS NOT YET READY!

2 Lab 2 System calls Single user program Memory issues Console Lab 2 :: Systems Calls At High Level System calls: communication between the user program and the kernel functions, called from the user program and performed by the kernel computers often use interrupts to accomplish that switch from user code to system code

3 Lab 2:: Systems Calls At High Level user_program.c bool flag; Calling flag = create( file.txt, 1000); corresponding function in the wrapper Calling corresponding exception in Pintos kernel the kernel System call wrapper pintos/src/lib/user/syscall.c bool create (const char *file, unsigned initial_size) { return syscall2 (SYS_CREATE, file, initial_size); User exception handler // Your code here! Return result back to the user program pintos/src/userprog/syscall.c Return result back to the wrapper Lab 2::What to Implement? You will need to implement: create - creates a file. open - opens a file. close - closes a file. read - reads from a file or the console (the keyboard). write - writes to a file or the console (the monitor). halt - halts the processor. exit - Terminates a program and deallocates resources occupied by the program, for example, closes all files opened by the program.

4 Lab 2::Useful Files You have to have a look at: pintos/src/lib/user/syscall[.h.c] the wrapper userprog/syscall[.h.c] Your implementation of system calls!!! threads/interrupt.[h c] important structures!!! lib/syscall-nr.h system call constants filesys/filesys.[h c] Pintos file system implementation examples/lab2test.c the official test program for this lab filesys/file.[h c] useful functions for operations with files. Things which you don t find in filesys, you find here userprog/process.c Look up what is here and tell me Lab 2::How Do I Start? (1) STEP 1 Understand what the user program is Look into examples directory and a couple of the user programs, especially halt.c Look into Makefile in this directory to understand how the user programs are compiled Compile the user programs by gmake STEP 2 Prepare Pintos disk Copy one or two user programs to the disk

5 Lab 2::How Do I Start? (2) STEP 2 (Continuation) Dealing with Pintos disk In userprog/build : pintos-mkdisk fs.dsk 2 This will create a file fs.dsk with a 2MB simulated disk in the directory. Format: pintos --qemu -- -f -q. Copy user programs: pintos --qemu -p programname -- -q with new name pintos --qemu -p programname -a newname -- -q Lab 2::How Do I Start? (3) STEP 2 (Continuation) Dealing with Pintos disk Example: pintos --qemu -p../../examples/halt -a severe_student_program -- -q To copy a file from the disk: pintos --qemu -g programname -- -q or pintos --qemu -g programname -a newname -- -q * -p = put, -g = get To run: pintos --qemu -- run programname Example: pintos --qemu -- run severe_student_program

6 Lab 2::How Do I Start? (4) STEP 3 into userprog/process.c, find setup_stack() *esp = PHYS_BASE; change to *esp = PHYS_BASE - 12; STEP 4 Make sure that you understand the problems which may arise if you access (in the kernel) data stored in the user memory using the pointers provided by the user program as system call arguments. (First, make sure that you understand what this sentence means ) Lab 2::Shutdown Example halt.c #include <syscall.h> int main (void){ halt (); userprog/syscall.c #include "userprog/syscall.h #include <stdio.h> #include <syscall-nr.h> get a name of the system callthread_exit (); SYS_HALT from the stack use power_off() #include "threads/interrupt.h #include "threads/thread.h static void syscall_handler (struct intr_frame *); voidsyscall_init (void) { intr_register_int (0x30, 3, INTR_ON, syscall_handler, "syscall"); static void syscall_handler (struct intr_frame *f UNUSED) printf ("system call!\n");! f->esp stack pointer

7 Lab 2::Shutdown Example static void syscall_handler (struct intr_frame *f) { // printf ("system call!\n"); int syscall_name; syscall_name = *(int *)(f->esp); switch(syscall_name) { case SYS_HALT: printf("halt system call\n"); power_off(); break; default: printf("unknown syscall %d\n", syscall_name); 13 Lab 2::Create Example bool create (const char *file, unsigned initial_size) Example: create( file.txt, 1000); How to get them? Answer: f->esp Hint: note that, in order to get a string, you will need get a void pointer from esp and then get a char pointer to which points that void pointer. The char pointer will point to the first element of the string How to return a value? Answer: f->eax

8 Lab 2::Create Example void SysCall_Create(struct intr_frame *f) { char *file_name; int file_size; printf("create system call\n"); file_name = (char *)*(int *)(f->esp + 4); file_size = *(int *)(f->esp + 8); if (filesys_create(file_name, file_size)) f->eax = true; else f->eax = false; case SYS_CREATE: SysCall_Create(f); break; 15 All the pointers on the variables, which you get from the user program, must be validated!

9 Problem 1: If the pointer above PHYS_BASE, It points to Kernel memory! UNSAFE! 17 Memory Issues in Pintos Kernel VM Physical Memory Kernel process PHYS_BASE User process Page directory If no entry? a)kill user b) Handle page fault

10 Lab 2::Memory Issues in Pintos Kernel VM Physical Memory Kernel process PHYS_BASE Check if the pointer is below User process Page directory Check if the pointer is in the page directory If no entry? a)kill user b) Handle page fault STRUCT THREAD 20

11 Lab 2::Shutdown Security (Safety?) static void syscall_handler (struct intr_frame *f) { int syscall_name; You have to implement validate_user_ptr(f->esp); validate_user_ptr(void *) syscall_name = *(int *)(f->esp); function to check if switch(syscall_name) { the pointer is case SYS_HALT: in the user space and printf("halt system call\n"); in the page directory! power_off(); break; default: printf("unknown syscall %d\n", syscall_name); 21 Lab 2::Create Security void SysCall_Create(struct intr_frame *f) { char *file_name; int file_size; printf("create system call\n"); validate_user_ptr(f->esp + 4) A string can span across several pages in memory! validate_user_ptr_str((void *)*(int *)(f->esp + 4)) file_name = (char *)*(int *)(f->esp + 4); validate_user_ptr(f->esp + 8) file_size = *(int *)(f->esp + 8); if (filesys_create(file_name, file_size)) f->eax = true; else f->eax = false; All pointers of the string have to be valid. You should provide an efficient solution to validate as less string pointers as possible! 22

12 Lab 2::Other System Calls To implement the system calls, which operate with files, look at filesys/filesys.[h c] and filesys/file.[h c] (except the console) Everything is already done there for you! Just call the functions! But don t forget validation of system call parameters! Lab 2::Open and Close int open (const char *file) void close (int fd) Sink when you manage file IDs but not too deep! I suggest using an array of *file elements and return indexes of this array as file IDs 0 and 1 IDs must be always reserved for the console!

13 Lab 2::Read System Call int read (int fd, void *buffer, unsigned size) Reads size bytes from the file open as fd into buffer. Returns the number of bytes actually read (0 at end of file), or -1 if the file could not be read (due to a condition other than end of file). Fd 0 reads from the keyboard using input_getc() (defined in devices/input.h). Lab 2::Write System Call int write (int fd, const void *buffer, unsigned size) Writes size bytes from buffer to the open file fd Returns the number of bytes actually written or -1 if the file could not be written The expected behavior is to write as many bytes as possible up to end-of-file and return the actual number written or -1 if no bytes could be written at all When fd=1 then the system call should write to the console with just one call to putbuf() (check lib/kernel/stdio.h and lib/kernel/console.c)

14 Lab 2::Console The reading from the console should be done in a convenient way: You should implement echo The typing should be permitted until Enter is pressed (ASCII code 13) Do not use the graphical qemu terminal for keyboard input (it behaves strangely), instead use the terminal from which you start pintos Only the requested number of characters passed in a read system call should be stored (for example, 10), the rest should be ignored Do not forget to add NULL character at the end of the string that you have read. Lab 2::Exit System Call void exit (int status) Terminates the current user program, returning status to the kernel. Conventionally, a status of 0 indicates success and nonzero values indicate errors. Remember to free all the resources will be not needed anymore. This system call will be improved in the following labs. Important: Free resource in process_exit() function located in process.c CLOSE ALL OPEN FILES

15 Lab 3:: General Description Lab 3: Execution, termination and synchronization of user programs Handling program arguments Execution of several user programs Termination of a user program Synchronization of shared data structures Wait system call

16 Lab 3::Main Goals Part A Provide synchronization for multiple programs Provide synchronization between programs (the most important part of the lab) Part B Loading program arguments (probably, was the most difficult part of the lab) File synchronization: Not yet addressed. It is a part of Lab 4 Lab 3::Exec, Exit and Wait (1) pid_t exec (const char *cmd_line) Runs the executable whose name is given in cmd_line, passing any given arguments, and returns the new process s program id (pid) Must return pid -1, if the program cannot load or run for any reason (!)

17 Lab 3::Exec, Exit and Wait (2) void exit (int status) Terminates the current user program, returning the exit code status to the kernel. status of 0 indicates success and nonzero values indicate errors Remember to free all the resources that will be not needed anymore. Lab 3::Exec, Exit and Wait (3) int wait (pid t pid) Provides synchronization between user programs. "Parent" process waits until its pid-"child" process dies (if the child is still running) and receives the "child" exit code. If the child has been finished, wait() should return child's exit value without waiting. Seems to be difficult? Not really

18 pid = process ID tid = thread ID Lab 3::Exec Add your implementation of exec() functionalities into process_execute() and process_start() in process.c Your Exec() system call in syscall.c { f-eax = process_execute process_execute() { tid = thread_create generate pid from tid; wait until start_process(); return pid or -1 start_process() { loading DONE! initialization DONE! putting program arguments into stack is a PART B; signal to process_execute pid = -1, if the program cannot load or run for any reason. Use an array or a list to keep track of pid:s. pid might equal tid, because we have only one thread per process. Limit the number of user programs (t.ex. 64 or 128). Lab 3::Exit (1) The most suitable place for Exit() functionalities is in your implementation of systems calls in syscall.c Your Exit() system call in syscall.c { get exit code from user; save the exit code if needed; thread_exit thread_exit() { process_exit process_exit() { clean up program s resources; Exit() must return -1 to the parent program if something is wrong, for example, if the child has caused a memory violation. You should take care of it! Clean up program s resources before the exit! printf("%s: exit(%d)\n", thread-name, thread-exit-value) before any exit. (This is needed for testing purposes.)

19 Lab 3::Exit (2) Lab 3::Wait Once you get pid, just call process_wait() (located in process.c) from Wait() system call: Steps to accomplish wait(): 1.Wait until the exit code of child pid is available 2.Get the exit code and remove it from the system 3.Return the exit code (or -1 if something is wrong)

20 Lab 3::Situations with Wait (1) "Parent" exits without calling wait() while the "child" is still running "Child" exits before the "parent" and: "parent" calls wait() afterwards, or "parent" will exit without calling wait(). "Parent" calls wait() before the "child" exits. +All the situations above under the condition that the child does not exit normally. Lab 3::Situations with Wait (2) "Parent" exits without calling wait() while the "child" is still running Child exit(0) Parent exec(child) Do not store the exit code! exit(0)

21 Lab 3::Situations with Wait (3) "Child" exits before the "parent" and: "parent" calls wait() afterwards Child exit(0) keep the exit value Destroy the exit value! Parent exec(child) wait(child) exit(0) wait() returns child s exit value without waiting Lab 3::Situations with Wait (4) "Child" exits before the "parent" and: "parent" will exit without calling wait(). Child exit(0) keep the exit value Destroy the exit value! Parent exec(child) exit(0) You should keep child s exit value until the parent exits (since the child doesn t know if the parent calls wait() later on)

22 Lab 3::Situations with Wait (5) "Parent" calls wait() before the "child" exits. Child Destroy the exit value! exit(0) Parent exec(child) wait for the child wait(child) exit(0) the parent waits for its child Lab 3::Situations with Wait (6) +All the situations above under the condition that the child does not exit normally. Do it as a homework!

23 Lab 3::To Hit The Target! 1. Parts of the functions accessing shared resources must be thread safe, e.g. employ synchronization techniques such as locks and semaphores. 2. Particularly, access to global objects and data must be synchronized. 3. Only one thread can have access to the console at a time. Other threads must wait until completion of reading/writing. 45 To debug: /* grandfather.c */ #include <syscall.h> #include <stdio.h> int main (void){ int pid1, pid2, pid3; pid1 = exec("parent1"); wait(pid1); pid2 = exec("parent2"); wait(pid2); pid3 = exec("parent3"); wait(pid3); exit(0); Lab 3::Test (2) /* parentx.c */ #include <syscall.h> #include <stdio.h> int main (void){ int i; int pid[10]; for(i = 0; i < 10; i++) { pid[i] = exec("childx"); for(i = 0; i < 10; i++) { wait(pid[i]); exit(0); 46

24 Lab 3::Test (3) /* childx.c */ #include <syscall.h> #include <stdio.h> int main (void){ int i; for(i = 0; i < 20000; i++) { int a = (i * i) + (i * i); int b = i; i = a; a = b; i = b; write(1, PASS Lab X ON Time.\n,20); exit(0); Create 1 grandfather, 3 parents and 3 children in examples directory: grandfather.c parent1.c parent2.c parent3.c child1.c child2.c child3.c Replace X in all the places in the code for parents and children with 1, 2, and 3, respectively. 47 Lab 3::Test (4) Modify Makefile in examples, such that all the programs are compiled: PROGS = parent1 parent2 parent3 child1 \ child2 child3 grandfather parent1_src = parent1.c child1_src = child1.c parent2_src = parent2.c child2_src = child2.c parent3_src = parent3.c child3_src = child3.c grandfather_src = grandfather.c Compile the programs with gmake. 48

25 Lab 3::Test (5) Copy them all on the Pintos disk in userprog (don t forget to create the disk and format it). Start them as pintos --qemu -- run grandfather As the output programs should print: Firstly, all 10 PASS Lab 1 ON Time. Secondly, all 10 PASS Lab 2 ON Time. Thirdly, all 10 PASS Lab 3 ON Time. Then, try to comment some wait() in grandfather and parents to see how it behaves. The order should be destroyed (Don t forget to recompile the programs and copy on the disk again. 49 You may need to format the disk before.) Lab 3::Part B (PB) Task: Load program arguments. GOOD NEWS: You will receive the source code once you are done with Part B BAD NEWS: The code will contain a couple of nasty bugs 50

26 Lab 3::PB::Preparatory Steps (1) Lab 2::STEP 3 into userprog/process.c, find setup_stack() *esp = PHYS_BASE; change to *esp = PHYS_BASE - 12; So that you have *esp = PHYS_BASE; CHANGE IT BACK! 51 Lab 3::PB::Preparatory Steps (2) Before continuing, explain why you have "KERNEL PANIC" after you have removed "-12". What is wrong and why did the program work before? 52

27 Lab 3::PB::Preparatory Steps (3) The user program with arguments should be called with '...' from the Pintos command line: pintos --qemu -- run nasty_program arg1 arg2 arg3 When the user program with arguments is called from exec(), you have to call it like this: exec("nasty_program arg1 arg2 arg3") The implementation of all these things have to be done in start_process() 53 pid = process ID tid = thread ID Lab 3::PB::Exec Add your implementation of exec() functionalities into process_execute() and process_start() in process.c Your Exec() system call in syscall.c { f-eax = process_execute process_execute() { tid = thread_create generate pid from tid; wait until start_process(); return pid or -1 start_process() { loading DONE! initialization DONE! putting program arguments into stack is a PART B; signal to process_execute pid = -1, if the program cannot load or run for any reason. Use an array or a list to keep track of pid:s. pid might equal tid, because we have only one thread per process. Limit the number of user programs (t.ex. 64 or 128).

28 Lab 3::PB::Implementation (1) STEP 1. Parse the string: Use strtok_r(), prototyped in lib/string.h Read comments in lib/string.c or man page (run man strtok_r) Limit the number of arguments (for simplicity) STEP 2. Set up the stack: Necessary details about setting up the stack for this task you can find in Program Startup 55 Details section of Pintos documentation. Lab 3::PB::Implementation (2) nasty_program arg1 arg2 arg3 After parsing: nasty_program, arg1, arg2, arg3 Place the words at the top of the stack Align to 4-byte-words, add 0 s Reference the words through the pointers (pointers should point to the addresses of the words in the stack) Put the pointers to the stack (followed with NULL pointer) 56

29 Lab 3::PB::Implementation (2) Put the address of the first pointer to the stack Put the number of words to the stack (the number of arguments + 1) Put faked return address to the stack (e.g. NULL). This is needed in order to meet x86 conventions for program arguments, even though this return address will not be used. So, what we get if we assume that PHYS_BASE is 0xc Address 0xbffffffb 0xbffffff6 0xbffffff1 0xbfffffe3 0xbfffffe0 0xbfffffdc 0xbfffffd8 0xbfffffd4 0xbfffffd0 0xbfffffcc 0xbfffffc8 0xbfffffc4 0xbfffffc0 Name argv[3][...] argv[2][...] argv[1][...] argv[0][...] word-align argv[4] argv[3] argv[2] argv[1] argv[0] argv argc return address Data arg3\0 arg2\0 arg1\0 nasty_program\ > xbffffffc 0xbffffff8 0xbffffff4 0xbfffffe6 0xbfffffd0 4 0 Type char[5] char[5] char[5] char[14] uint24_t char * char * char * char * char * char ** int 58 void (*) ()

30 Lab 3::Test (1) Now you are ready for a complete check! Run gmake check from userprog/build The following tests should pass: 1) Argument passing when executing: args-none, args-single, args-multiple, args-many, args-dbl-space 2) Different exec-tests: exec-once, exec-arg, exec-multiple, exec-missing, exec-bad-ptr 3) Wait-tests: wait-simple, wait-twice, wait-killed, wait-bad-pid 59 Lab 3::Test (2) Many of the other checks in gmake check belong to the second lab. If any of them fails, then it means that something is wrong with your implementation of Lab 2: sc-bad-sp, sc-bad-arg, sc-boundary, sc-boundary-2, halt, exit, create-normal, create-empty, create-null, create-bad-ptr, create-long, create-exists, create-bound, open-normal, open-missing, open-boundary, open-empty, open-null, open-bad-ptr, open-twice, close-normal, close-stdin, close-stdout, close-bad-fd, read-bad-ptr, read-boundary, read-zero, read-stdout, read-bad-fd, write-normal, write-bad-ptr, write-boundary, write-zero, write-stdin, write-bad-fd 60

31 Lab 2 & Lab 3 Lab 2 13th of February Lab 3 5th of March Discussion about Lab 4 + Repetition of Lab 3 next lesson 61

Laboratory work in TDDB68 Pintos Assignments 2, 3. Viacheslav Izosimov

Laboratory work in TDDB68 Pintos Assignments 2, 3. Viacheslav Izosimov Laboratory work in TDDB68 Pintos Assignments 2, 3 Viacheslav Izosimov 2007-09-18 viaiz@ida.liu.se Timeline Lab 2: System calls Description Pintos stack Pintos memory Pintos file system Halt, Exit Create,

More information

According to this plan, you should have started with Lab 2 now Around 50% have passed Lab 1. The environment (1)

According to this plan, you should have started with Lab 2 now Around 50% have passed Lab 1. The environment (1) TDDB68 Lesson 2 Pintos Assignments 2 & 3 Mattias Eriksson 2009 mater@ida.liu.se some slides by Viacheslav Izosimov 2007-2008 Comments on muddy card evaluation Environment to build, run and test on Windows/

More information

TDDB68 Lesson 2 Pintos Assignments 3 & 4. Mattias Eriksson 2010 (or

TDDB68 Lesson 2 Pintos Assignments 3 & 4. Mattias Eriksson 2010 (or TDDB68 Lesson 2 Pintos Assignments 3 & 4 Mattias Eriksson 2010 mater@ida.liu.se (or mattias.eriksson@liu.se) some slides by Viacheslav Izosimov 2007-2008 Instead of Motivation Plan for something like this:

More information

TDDB Lesson 3 Pintos Assignments (2), 3 & 4. Erik Hansson

TDDB Lesson 3 Pintos Assignments (2), 3 & 4. Erik Hansson TDDB68 2015 Lesson 3 Pintos Assignments (2), 3 & 4 Erik Hansson erik.hansson@liu.se Most slides by Mattias Eriksson 2009-2010 and Viacheslav Izosimov 2007-2008 Remember Pass assignments on time to get

More information

User Programs. Computer Systems Laboratory Sungkyunkwan University

User Programs. Computer Systems Laboratory Sungkyunkwan University Project 2: User Programs Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Supporting User Programs What should be done to run user programs? 1. Provide

More information

Project 2: User Programs

Project 2: User Programs Project 2: User Programs CS140 - Winter 2010 Slides by Andrew He, adapted from previous CS140 offerings Overview Project 2 is due Thursday, February 4 This project requires an understanding of: How user

More information

Project 2-1 User Programs

Project 2-1 User Programs Project 2-1 User Programs Prof. Jin-Soo Kim ( jinsookim@skku.edu) T.A. Sejun Kwon (sejun000@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Supporting User Programs

More information

TDDB Lesson 2 Pintos Assignments (2), 3 & 4. Erik Hansson

TDDB Lesson 2 Pintos Assignments (2), 3 & 4. Erik Hansson TDDB68 2013 Lesson 2 Pintos Assignments (2), 3 & 4 Erik Hansson erik.hansson@liu.se Most slides by Mattias Eriksson 2009-2010 and Viacheslav Izosimov 2007-2008 Instead of Motivation Some of you should

More information

TDDB68 Lesson 3. Simon Ståhlberg

TDDB68 Lesson 3. Simon Ståhlberg TDDB68 Lesson 3 Simon Ståhlberg Contents Overview of lab 3 A: Exec, wait, exit B: Program arguments C: Termination of ill-behaving user processes Testing your implementation Overview of lab 4 File system

More information

Project 2: User Programs

Project 2: User Programs Project 2: User Programs Presented by Jaishankar Sundararaman 21 February 2008 Till now All code part of Pintos Kernel Code compiled directly with the kernel This required that the tests call some functions

More information

TDDB Lesson 3 Pintos Assignments (2), 3 & 4. Erik Hansson

TDDB Lesson 3 Pintos Assignments (2), 3 & 4. Erik Hansson TDDB68 2016 Lesson 3 Pintos Assignments (2), 3 & 4 Erik Hansson erik.hansson@liu.se Most slides by Mattias Eriksson 2009-2010 and Viacheslav Izosimov 2007-2008 Plan your time Plan your time with your

More information

CS 140 Project 2: User Programs. Fall 2015

CS 140 Project 2: User Programs. Fall 2015 CS 140 Project 2: User Programs Fall 2015 Important Dates Project 1: DUE TODAY (Friday, October 9 th ) at 12pm Project 2 will be due Friday, October 23 rd at 12pm 2 weeks Start early J 2 Overview Project

More information

Project 2--User Programs

Project 2--User Programs Project 2--User Programs Jason Bau CS140 Winter 09 Slides Acknowledgements to previous CS140 TAs User Program/Process What happens in Unix shell when? myth13:~/> cp r pintos. 1. Shell handles user input

More information

Pintos Project 2 User Programs. September 28, 2016

Pintos Project 2 User Programs. September 28, 2016 Pintos Project 2 User Programs September 28, 2016 Overview What are user programs? Anything you run on the command line: ~$ls ~$git push ~$./my_project arg1 arg2 Overview of Part 1: Setup Stack User Hey

More information

TDDB68. Lesson 1. Simon Ståhlberg

TDDB68. Lesson 1. Simon Ståhlberg TDDB68 Lesson 1 Simon Ståhlberg Contents General information about the labs Overview of the labs Memory layout of C programs ("Lab 00") General information about Pintos System calls Lab 1 Debugging Administration

More information

TDDB68 Lesson 1 Introduction to Pintos Assignments 00, 0, 1, 2

TDDB68 Lesson 1 Introduction to Pintos Assignments 00, 0, 1, 2 TDDB68 Lesson 1 Introduction to Pintos Assignments 00, 0, 1, 2 Mattias Eriksson 2010 mater@ida.liu.se Some slides by Viacheslav Izosimov 2007-2008 Outline Administration Introduction to Pintos Important

More information

Pintos Project 2 User Programs

Pintos Project 2 User Programs 1 Pintos Project 2 User Programs COS 450 - Fall 2018 Project 1 Submissions Easy Things to Fix 2 Project submission Code style ASSERT and malloc() Design document questions Code Style 1.2.2.2 3 Match the

More information

Project-2 Review. (Extending the functionality of PintOS user program implementation) Summer 2018

Project-2 Review. (Extending the functionality of PintOS user program implementation) Summer 2018 Project-2 Review (Extending the functionality of PintOS user program implementation) Summer 2018 Overview Necessities and Organization Argument passing in PintOS Implementation of System Calls Metedata

More information

TDDB Lesson 2 Introduction to Pintos Assignments (1) and 2

TDDB Lesson 2 Introduction to Pintos Assignments (1) and 2 TDDB68 2015 Lesson 2 Introduction to Pintos Assignments (1) and 2 Erik Hansson erik.hansson@liu.se Most slides by Mattias Eriksson 2009-2010 and Viacheslav Izosimov 2007-2008. Outline Administration Introduction

More information

Project 3: Virtual Memory

Project 3: Virtual Memory Project 3: Virtual Memory Prof. Jin-Soo Kim ( jinsookim@skku.edu) TA Bak jin-yeong (dongdm@gmail.com) Go gyeong-min (gkm2164@gmail.com) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu

More information

Project 4: Virtual Memory

Project 4: Virtual Memory Project 4: Virtual Memory by Ben Pfaff USF modifications by Greg Benson Chapter 1: Project 4: Virtual Memory 1 1 Project 4: Virtual Memory By now you should be familiar with the inner workings of Pintos.

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

Operating Systems and Networks Assignment 2

Operating Systems and Networks Assignment 2 Spring Term 2014 Operating Systems and Networks Assignment 2 Assigned on: 27th February 2014 Due by: 6th March 2014 1 Scheduling The following table describes tasks to be scheduled. The table contains

More information

SYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14

SYSTEM CALL IMPLEMENTATION. CS124 Operating Systems Fall , Lecture 14 SYSTEM CALL IMPLEMENTATION CS124 Operating Systems Fall 2017-2018, Lecture 14 2 User Processes and System Calls Previously stated that user applications interact with the kernel via system calls Typically

More information

Project #1 Exceptions and Simple System Calls

Project #1 Exceptions and Simple System Calls Project #1 Exceptions and Simple System Calls Introduction to Operating Systems Assigned: January 21, 2004 CSE421 Due: February 17, 2004 11:59:59 PM The first project is designed to further your understanding

More information

Section 7: Wait/Exit, Address Translation

Section 7: Wait/Exit, Address Translation William Liu October 15, 2014 Contents 1 Wait and Exit 2 1.1 Thinking about what you need to do.............................. 2 1.2 Code................................................ 2 2 Vocabulary 4

More information

Midterm Exam #2 April 20, 2016 CS162 Operating Systems

Midterm Exam #2 April 20, 2016 CS162 Operating Systems University of California, Berkeley College of Engineering Computer Science Division EECS Spring 2016 Anthony D. Joseph Midterm Exam #2 April 20, 2016 CS162 Operating Systems Your Name: SID AND 162 Login:

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

Pebbles Kernel Specification September 26, 2004

Pebbles Kernel Specification September 26, 2004 15-410, Operating System Design & Implementation Pebbles Kernel Specification September 26, 2004 Contents 1 Introduction 2 1.1 Overview...................................... 2 2 User Execution Environment

More information

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C. Structure Unix architecture users Functions of the System tools (shell, editors, compilers, ) standard library System call Standard library (printf, fork, ) OS kernel: processes, memory management, file

More information

LAB3: VIRTUAL MEMORY. Operating Systems 2015 Spring by Euiseong Seo

LAB3: VIRTUAL MEMORY. Operating Systems 2015 Spring by Euiseong Seo LAB3: VIRTUAL MEMORY Operating Systems 2015 Spring by Euiseong Seo Background: Paging (1) Paging in the x86 architecture Background: Paging (2) Current Pintos VM implementation Use paging Page size: 4KB

More information

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

CSci 4061 Introduction to Operating Systems. Programs in C/Unix CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,

More information

by Marina Cholakyan, Hyduke Noshadi, Sepehr Sahba and Young Cha

by Marina Cholakyan, Hyduke Noshadi, Sepehr Sahba and Young Cha CS 111 Scribe Notes for 4/11/05 by Marina Cholakyan, Hyduke Noshadi, Sepehr Sahba and Young Cha Processes What is a process? A process is a running instance of a program. The Web browser you're using to

More information

Section 4: Threads CS162. September 15, Warmup Hello World Vocabulary 2

Section 4: Threads CS162. September 15, Warmup Hello World Vocabulary 2 CS162 September 15, 2016 Contents 1 Warmup 2 1.1 Hello World............................................ 2 2 Vocabulary 2 3 Problems 3 3.1 Join................................................ 3 3.2 Stack

More information

Lab 09 - Virtual Memory

Lab 09 - Virtual Memory Lab 09 - Virtual Memory Due: November 19, 2017 at 4:00pm 1 mmapcopy 1 1.1 Introduction 1 1.1.1 A door predicament 1 1.1.2 Concepts and Functions 2 1.2 Assignment 3 1.2.1 mmap copy 3 1.2.2 Tips 3 1.2.3

More information

Section 4: Threads and Context Switching

Section 4: Threads and Context Switching CS162 September 19-20, 2017 Contents 1 Warmup 2 1.1 Hello World............................................ 2 2 Vocabulary 2 3 Problems 3 3.1 Join................................................ 3 3.2

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

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

Project 5: File Systems

Project 5: File Systems Project 5: File Systems by Ben Pfaff USF modifications by Greg Benson Chapter 1: Project 5: File Systems 1 1 Project 5: File Systems In the previous two assignments, you made extensive use of a file system

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

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

A2 Design Considerations. CS161, Spring

A2 Design Considerations. CS161, Spring A2 Design Considerations CS161, Spring 2014 http://goo.gl/izxych Agenda 1. processes 2. file descriptors 3. fork 4. waitpid & exit 5. exec 6. scheduler 7. suggestions for testing 8. lessons learned from

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

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

SE350: Operating Systems

SE350: Operating Systems SE350: Operating Systems Tutorial: The Programming Interface Main Points Creating and managing processes fork, exec, wait Example: implementing a shell Shell A shell is a job control system Allows programmer

More information

CS 350 : COMPUTER SYSTEM CONCEPTS SAMPLE TEST 2 (OPERATING SYSTEMS PART) Student s Name: MAXIMUM MARK: 100 Time allowed: 70 minutes

CS 350 : COMPUTER SYSTEM CONCEPTS SAMPLE TEST 2 (OPERATING SYSTEMS PART) Student s Name: MAXIMUM MARK: 100 Time allowed: 70 minutes CS 350 : COMPUTER SYSTEM CONCEPTS SAMPLE TEST 2 (OPERATING SYSTEMS PART) Student s Name: MAXIMUM MARK: 100 Time allowed: 70 minutes Q1 (30 marks) NOTE: Unless otherwise stated, the questions are with reference

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

Lab 8. Follow along with your TA as they demo GDB. Make sure you understand all of the commands, how and when to use them.

Lab 8. Follow along with your TA as they demo GDB. Make sure you understand all of the commands, how and when to use them. Lab 8 Each lab will begin with a recap of last lab and a brief demonstration by the TAs for the core concepts examined in this lab. As such, this document will not serve to tell you everything the TAs

More information

Processes (Intro) Yannis Smaragdakis, U. Athens

Processes (Intro) Yannis Smaragdakis, U. Athens Processes (Intro) Yannis Smaragdakis, U. Athens Process: CPU Virtualization Process = Program, instantiated has memory, code, current state What kind of memory do we have? registers + address space Let's

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

Project 1 System Calls

Project 1 System Calls Project 1 System Calls Introduction In this project, you will become familiar with: 1. Using the xv6 Makefile 2. Using conditional compilation. 3. The xv6 system call invocation path. 4. Implementing a

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

Control Flow. Systemprogrammering 2007 Föreläsning 2 Exceptional Control Flow Part I. Exceptional Control Flow. Altering the Control Flow

Control Flow. Systemprogrammering 2007 Föreläsning 2 Exceptional Control Flow Part I. Exceptional Control Flow. Altering the Control Flow Systemprogrammering 2007 Föreläsning 2 Exceptional Control Flow Part I Topics Exceptions Process context switches Creating and destroying processes Control Flow Computers do Only One Thing From startup

More information

CSCE Operating Systems Interrupts, Exceptions, and Signals. Qiang Zeng, Ph.D. Fall 2018

CSCE Operating Systems Interrupts, Exceptions, and Signals. Qiang Zeng, Ph.D. Fall 2018 CSCE 311 - Operating Systems Interrupts, Exceptions, and Signals Qiang Zeng, Ph.D. Fall 2018 Previous Class Process state transition Ready, blocked, running Call Stack Execution Context Process switch

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

CS 140 Project 4 File Systems Review Session

CS 140 Project 4 File Systems Review Session CS 140 Project 4 File Systems Review Session Prachetaa Due Friday March, 14 Administrivia Course withdrawal deadline today (Feb 28 th ) 5 pm Project 3 due today (Feb 28 th ) Review section for Finals on

More information

Exceptional Control Flow Part I

Exceptional Control Flow Part I Exceptional Control Flow Part I Today! Exceptions! Process context switches! Creating and destroying processes Next time! Signals, non-local jumps, Fabián E. Bustamante, 2007 Control flow! Computers do

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

Altering the Control Flow

Altering the Control Flow Altering the Control Flow Up to Now: two mechanisms for changing control flow: Jumps and branches Call and return using the stack discipline. Both react to changes in program state. Insufficient for a

More information

Processes & Threads. (Chapter 3) CS 4410 Operating Systems. [R. Agarwal, L. Alvisi, A. Bracy, M. George, E. Sirer, R. Van Renesse]

Processes & Threads. (Chapter 3) CS 4410 Operating Systems. [R. Agarwal, L. Alvisi, A. Bracy, M. George, E. Sirer, R. Van Renesse] Processes & Threads (Chapter 3) CS 4410 Operating Systems [R. Agarwal, L. Alvisi, A. Bracy, M. George, E. Sirer, R. Van Renesse] Processes! 2 What is a Program? Program is a file containing: executable

More information

CS61 Scribe Notes Lecture 18 11/6/14 Fork, Advanced Virtual Memory

CS61 Scribe Notes Lecture 18 11/6/14 Fork, Advanced Virtual Memory CS61 Scribe Notes Lecture 18 11/6/14 Fork, Advanced Virtual Memory Roger, Ali, and Tochi Topics: exploits fork shell programming rest of course announcements/ending (for later info) final (not as time

More information

Section 7: Scheduling and Fairness

Section 7: Scheduling and Fairness March 1-2, 2018 Contents 1 Warmup 2 2 Vocabulary 2 3 Problems 3 3.1 Scheduling............................................. 3 3.2 Simple Priority Scheduler.................................... 4 3.2.1 Fairness..........................................

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

Exceptional Control Flow Part I

Exceptional Control Flow Part I Exceptional Control Flow Part I Today Exceptions Process context switches Creating and destroying processes Next time Signals, non-local jumps, Chris Riesbeck, Fall 2011 Original: Fabian Bustamante Control

More information

Exceptional Control Flow Part I Oct. 17, 2002

Exceptional Control Flow Part I Oct. 17, 2002 15-213 The course that gives CMU its Zip! Exceptional Control Flow Part I Oct. 17, 2002 Topics Exceptions Process context switches Creating and destroying processes class16.ppt Control Flow Computers do

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

CS 550 Operating Systems Spring Process III

CS 550 Operating Systems Spring Process III CS 550 Operating Systems Spring 2018 Process III 1 Recap: Memory Layout of a typical process MAX Stack Function Call Arguments, Return Address, Return Values Gap Heap Data Dynamically allocated memory

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

Processes. CS439: Principles of Computer Systems January 30, 2019

Processes. CS439: Principles of Computer Systems January 30, 2019 Processes CS439: Principles of Computer Systems January 30, 2019 What We Know Operating system complexity increased over time in response to economic and technological changes The three roles did not show

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

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

CS 326: Operating Systems. Process Execution. Lecture 5

CS 326: Operating Systems. Process Execution. Lecture 5 CS 326: Operating Systems Process Execution Lecture 5 Today s Schedule Process Creation Threads Limited Direct Execution Basic Scheduling 2/5/18 CS 326: Operating Systems 2 Today s Schedule Process Creation

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

OS Lab Tutorial 1. Spawning processes Shared memory

OS Lab Tutorial 1. Spawning processes Shared memory OS Lab Tutorial 1 Spawning processes Shared memory The Spawn exec() family fork() The exec() Functions: Out with the old, in with the new The exec() functions all replace the current program running within

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

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

PRINCIPLES OF OPERATING SYSTEMS

PRINCIPLES OF OPERATING SYSTEMS PRINCIPLES OF OPERATING SYSTEMS Tutorial-1&2: C Review CPSC 457, Spring 2015 May 20-21, 2015 Department of Computer Science, University of Calgary Connecting to your VM Open a terminal (in your linux machine)

More information

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed Process Management CS 537 Lecture 3: Processes Michael Swift This lecture begins a series of topics on processes, threads, and synchronization Today: processes and process management what are the OS units

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

Pebbles Kernel Specification September 20, 2017

Pebbles Kernel Specification September 20, 2017 15-410, Operating System Design & Implementation Pebbles Kernel Specification September 20, 2017 Contents 1 Introduction 2 1.1 Overview.......................................... 2 2 User Execution Environment

More information

Inter-process communication (IPC)

Inter-process communication (IPC) Inter-process communication (IPC) Operating Systems Kartik Gopalan References Chapter 5 of OSTEP book. Unix man pages Advanced Programming in Unix Environment by Richard Stevens http://www.kohala.com/start/apue.html

More 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

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

CSE 333 SECTION 3. POSIX I/O Functions

CSE 333 SECTION 3. POSIX I/O Functions CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight Exercise 7 due Monday (out later today) POSIX Portable Operating System Interface Family of standards specified by the

More information

Giving credit where credit is due

Giving credit where credit is due CSCE 230J Computer Organization Exceptional Control Flow Part I Dr. Steve Goddard goddard@cse.unl.edu http://cse.unl.edu/~goddard/courses/csce230j Giving credit where credit is due Most of slides for this

More information

Project 2! CSE 421/521 - Operating Systems! Virtual Memory in Pintos

Project 2! CSE 421/521 - Operating Systems! Virtual Memory in Pintos Project 2! CSE 421/521 - Operating Systems! Virtual Memory in Pintos Deadline: December 4, 2013 @ 11.59pm Muhammed Fatih Bulut Preparation Chapters 8-9 from Silberschatz.! Lecture slides on Memory and

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

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

Project #1: Tracing, System Calls, and Processes

Project #1: Tracing, System Calls, and Processes Project #1: Tracing, System Calls, and Processes Objectives In this project, you will learn about system calls, process control and several different techniques for tracing and instrumenting process behaviors.

More information

Altering the Control Flow

Altering the Control Flow Altering the Control Flow Up to Now: two mechanisms for changing control flow: Jumps and branches Call and return using the stack discipline. Both react to changes in program state. Insufficient for a

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

Interrupts, Fork, I/O Basics

Interrupts, Fork, I/O Basics Interrupts, Fork, I/O Basics 12 November 2017 Lecture 4 Slides adapted from John Kubiatowicz (UC Berkeley) 12 Nov 2017 SE 317: Operating Systems 1 Topics for Today Interrupts Native control of Process

More information

W4118: OS Overview. Junfeng Yang

W4118: OS Overview. Junfeng Yang W4118: OS Overview Junfeng Yang References: Modern Operating Systems (3 rd edition), Operating Systems Concepts (8 th edition), previous W4118, and OS at MIT, Stanford, and UWisc Outline OS definitions

More information

Last time: introduction. Networks and Operating Systems ( ) Chapter 2: Processes. This time. General OS structure. The kernel is a program!

Last time: introduction. Networks and Operating Systems ( ) Chapter 2: Processes. This time. General OS structure. The kernel is a program! ADRIAN PERRIG & TORSTEN HOEFLER Networks and Operating Systems (252-0062-00) Chapter 2: Processes Last time: introduction Introduction: Why? February 12, 2016 Roles of the OS Referee Illusionist Glue Structure

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

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

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

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

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

Processes. What s s a process? process? A dynamically executing instance of a program. David Morgan

Processes. What s s a process? process? A dynamically executing instance of a program. David Morgan Processes David Morgan What s s a process? process? A dynamically executing instance of a program 1 Constituents of a process its code data various attributes OS needs to manage it OS keeps track of all

More information