According to this plan, you should have started with Lab 2 now Around 50% have passed Lab 1. The environment (1)
|
|
- Mervyn Fleming
- 5 years ago
- Views:
Transcription
1 TDDB68 Lesson 2 Pintos Assignments 2 & 3 Mattias Eriksson 2009 mater@ida.liu.se some slides by Viacheslav Izosimov Comments on muddy card evaluation Environment to build, run and test on Windows/ cygwin? /... on Linux? Appendix G in the Pintos manual. Known to work on Unix-like systems. I don't know about Cygwin. You can also ssh to astmatix Disable VGA (run qemu in terminal): pintos v C c won't stop Pintos now, use C a x to terminate Qemu 4 Instead of Motivation Plan for something like this: Lab 00, 0 Should be finished now Lab 1 10 th September (1 week) Lab 2 23 th September (2 weeks) Lab 3 9 th October (2 weeks) Lab 4 13 th October (½ week) Exam 20 th October According to this plan, you should have started with Lab 2 now Around 50% have passed Lab 1 Comments on muddy card evaluation Not enough space on user accounts sizeof(pintos) < 15 MB. Quota for this course: 20 MB. If you have run out of space it is probably because you have old files still on your account. Tip 1: check your quota quota v Tip 2: list your folders by size (kilobytes): cd ~ du sk ^..* sort n 15% are done with Lab The environment (1) Some of you are still struggling with the Unix environment It's difficult to learn, not difficult to use! Default prompt is not very helpful: mina10 <123> Make the prompt tell you which directory you are in: echo set prompt='%b%n@%m%b %c > ' >> ~/.cshrc.private Now every new prompt will something look like this: mater@mina10 ~/pintos/src/userprog > The environment (2) TAGS (emacs): finding the definition of a variable or an identifier cd pintos/src gmake TAGS emacs & M-. (hold down meta and press dot) Type malloc Emacs will jump to the declaration of malloc M-0 M-. will jump to the next tag matching malloc M-* jump back to the place where M-. was last Alternative: use a more modern shell, like bash 5 invoked (stack) 6
2 The environment (3) Subversion tips cd pintos/src svn up #get latest version from repository svn st #show which files are modified and new svn diff #show difference between working copy and most recently checked in revision svn -r 17 diff #same, but compared to revision 17 svn -r 17 -x -wp diff #ignore changes in whitespace and include context information svn log #show commit log The environment (4) (advanced subversion usage) Ignore this if you only do labs on a single IDA account Starting a subversion daemon cd svnrepository/conf Add users and passwords in authz and passwd Edit svnserve.conf to not allow anonymous access, and uncomment some lines... Login on to astmatix (astmatix reboots every day) svnserve d r $HOME/svnrepository listen port Pick a port number no one else is using (>1024) Now, on another computer: svn -v log #also list which files are modified svn co svn://astmatix.ida.liu.se:12345/pintos pintos 7 8 Lab 2 System calls program (only one at a time) Lab 1 programs run in the kernel System calls Console (keyboard, monitor) Program Drivers Hardware Syscall Handler (Scheduler) 10 Lab 2 Systems calls at a high level System calls: communication between user program and the kernel functions, called from the user program and performed by the kernel computers use interrupts to accomplish that switch from user code to system code Program Drivers Hardware Syscall Handler (Scheduler) 11 Pintos Lab 2: Pintos kernel overview Synchronization primitives File system Timer programs System call Interrupt handlers syscall, timer, kbd, etc Drivers Hardware Page table Scheduler Threads Lab 2 What to implement? You will need to implement these system calls: 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 allocated to it. (will be extended in Lab 3, don't worry about saving exit status yet.) LAB2
3 System calls Number of system calls Pintos Lab1: 0 Lab2: 7 Lab3: 9 Lab4: 13 Linux 319 system calls Windows More than 1000 system calls Lab 2 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 14 Lab 2: How Do I Start? (1) STEP 1: Understand what a user program is Look into the 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 issuing gmake 15 Lab 2: How Do I Start? (2) STEP 2: Dealing with Pintos disk Pintos uses a simulated hard-drive Can hold up to 16 files Filenames are up to 14 chars long To create it, do in userprog/build: pintos-mkdisk fs.dsk 2 This will create a file fs.dsk with a 2MB simulated disk in the directory. Format the simulated disk: pintos --qemu -- -f -q 16 Lab 2: How Do I Start? (3) Put a file on the disk: pintos --qemu -p../../examples/halt -a halt -- -q To examine the disk: pintos --qemu -- ls pintos --qemu -- cat filename pintos --qemu -- rm file1 rm file2 ls Example: to run halt: pintos -qemu -p../../examples/halt -a halt -- -q pintos --qemu -- run halt Tip: alias pintos pintos qemu 17 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: For now, make process_wait() an infinite loop or the kernel might power off too quickly Because the kernel calls process_wait on the first program. Hint: implement the Write system call (console part) early so that you can use printf() in user programs. 18
4 Lab 2: Shutdown Example The simplest user program: halt.c: #include <syscall.h> int main (void){ halt (); //shuts down the system This one is simple, do it first. Lab 2 Systems calls at a high level user_program.c bool flag; Calling flag = create( file.txt, 1000); corresponding function in the wrapper System call wrapper pintos/src/lib/user/syscall.c bool create (const char *file, unsigned initial_size) { return syscall2 (SYS_CREATE, file, initial_size); Calling corresponding exception in Pintos kernel the kernel syscall_handler(...){ // Your code here! Return result back to the user program pintos/src/userprog/syscall.c Return result back to the wrapper Lab 2: Create Example bool create (const char *file, unsigned size) Example: create( file.txt, 1000); How to retun a value? How to get them? Answer: f->eax Answer: they are passed on the stack: f->esp Hint: note that, in order to get a string, you will need get a pointer from esp. This pointer will point to the first element of the string The syscall2 macro explained /*return syscall2 (SYS_CREATE, file, initial_size);*/ #define syscall2(number, ARG0, ARG1) \ ({ \ int retval; \ asm volatile //Tell compiler to be careful \ //Put syscall arguments on the stack (long = 4 bytes) \ ("pushl %[arg1]; pushl %[arg0]; " \ "pushl %[number]; //Make interrupt nr 0x30 (syscall) int $0x30; //The interrupt handler will do some work now... //When it is done, forget the syscall arguments addl $12, %%esp" //3 words=12 bytes //Bind the symbols to our arguments \ : "=a" (retval) //output \ : [number] "i" (NUMBER), //input \ [arg0] "g" (ARG0), \ [arg1] "g" (ARG1) \ : "memory"); //clobbered \ retval; //retval will be the value of the expression\ 20 Lab 2: Create Example To implement the system calls, which operate with files, look at filesys/filesys.[h c] and filesys/file.[h c]. Everything is already done there for you! Just call the functions But what if the user program passes a bad pointer? e.g. create(null,0); the kernel would crash when reading the filename! you will fix this in Lab 3. The syscall handler Currently the syscall handler kills the thread You must: Get the syscall number Get the correct number of arguments Pointers and arrays are very related in C ptr + i == &(ptr[i]) static void syscall_handler (struct intr_frame *f UNUSED) { printf ("system call!\n"); thread_exit (); ) 24 21
5 Lab 2: File descriptors int open (const char *file) Open returns a file descriptor (fd) that is a handle to the open file Your task is to map the fd's to open files Need a list in the kernel To make it simple you are allowed to limit the number of files that can be open Pintos has a bitmap data structure that can help 0 and 1 must be always reserved for the The Pintos bitmap by example #include lib/kernel/bitmap.h #define FOOSIZE 128 static struct bitmap * foomap;... { /* Allocate memory for our bitmap */ foomap = bitmap_create (FOOSIZE); if (foomap == NULL) PANIC ("Map is too big"); /* Set 0th bit to 1 */ bitmap_mark (foomap, 0); /* Find a bit which is 0 and mark it */ int fnd = bitmap_scan_and_flip (foomap, 0, 1, 0); /* Free the bitmap (otherwise a leak) */ console! 25 bitmap_release (foomap); 26 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, or -1 if the file could not be read. Fd 0 == STDIN_FILENO Should read from the keyboard using input_getc() (see: devices/input.h). 27 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 Fd 1==STDOUT_FILENO use to putbuf() (check lib/kernel/stdio.h and lib/kernel/console.c) 28 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. This system call will be extended in Lab 3, for now you won't use status Important: Free resource in process_exit() function located in process.c CLOSE ALL OPEN FILES 29 Test program lab2test.c A small test program is provided, it will: Create files Open files Test console Try to use fake fd's Gotchas Remove all files before running it again: pintos qemu rm test0 rm test1 rm test2 Your Lab 2 implementation will be checked more thoroughly once Lab 3 is finished (gmake check) won't work now 30
6 Lab 3: General Description Lab 3: Execution, termination and synchronization of user programs Handling program arguments Execution of several user programs Termination of ill-behaving user programs Synchronization of shared data structures Part A Multiple user programs Lab 3: overview New system calls: exec & wait Extended system call from Lab 2: exit Careful synchronization in the kernel Lab 3 is tricky! Program1 Program2 Drivers Syscall Handler Program3 (Scheduler) Hardware 33 Part B Lab 3: overview program arguments cp foo bar : two arguments Part C Make the kernel robust to ill-behaving user programs Evil user program: create( (char *) 0, 1); Or worse, writing to kernel space: write( STDIN_FILENO, 0xc , 666 ); 34 Part A Lab 3: Exec pid_t exec (const char *cmd_line); Runs the executable whose name is given in cmd_line, passing any given arguments, returns the new process s program id (pid) Must return pid -1, if the program cannot load or run for any reason 35 Lab 3: Exit void exit (int status); Terminates the current user program, returning the exit code status to the kernel. By convention, status 0 indicates success and nonzero values often indicate errors. Remember to free all the resources that will be not needed anymore. files dynamically allocated memory 36
7 Lab 3: Wait 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. 37 pid = process ID (user space) tid = thread ID (kernel space) Syscall handler syscall.c { f-eax = process_execute The parent Lab 3: Exec process_execute() { tid = thread_create() FO generate pid from tid; wait until start_process(); return pid or -1 The child start_process() { load(binary); manipulate stack (Part B) signal to process_execute Problem: The loading of the binary is done in the child, hence the parent does not know at fork-time if loading will work Need synchronization! 38 syscall.c { get exit code from user; save the exit code if needed; thread_exit() Lab 3: Exit thread_exit() { process_exit() process_exit() { clean up program s resources; At exit, do: printf("%s: exit(%d)\n", thread name, thread exit value) This is needed for testing purposes (gmake check). 39 Lab 3: Situations with Wait Child exits before the parent and: parent calls wait() afterwards Lab 3: Situations with Wait Parent exits without calling wait() while the child is still running Lab 3: Situations with Wait Child exits before the parent and: parent will exit without calling wait(). Child keep the exit value Destroy the exit value! Child Child keep the exit value Destroy the exit value! Parent exec(child) wait(child) Parent exec(child) Parent exec(child) wait() returns child s exit value without waiting You should keep child s exit value until the parent exits (since the child doesn t know if the parent calls wait() later on)
8 Lab 3: Situations with Wait Parent calls wait() before the child exits. Parent Child exec(child) wait for the child wait(child) the parent waits for its child Destroy the exit value! 43 Reference counting poor man's garbage collector Parent Child needs a new data structure Who will free this memory depends on who exits last Many ways to implement this. Suggestion: you can use reference counting: struct child_status{ int exit_status; /*... */ int ref_cnt; ; child /* Initialize it */ struct child_status * cs = malloc... ; cs >ref_cnt = 2; /* both parent and child live */ parent /* When parent or child is done with cs: */ cs >ref_cnt ; /* Needs to be protected by a lock */ if ( cs >ref_cnt == 0 ){ free( cs ); cs 44 Lab 3: To Hit The Target! Parts of the functions accessing shared resources must be thread safe, e.g. employ synchronization techniques such as locks and semaphores. Particularly, access to global objects and data must be synchronized. Only one thread can have access to the console at a time. Other threads must wait until completion of reading/writing. 45 Lab 3: Part B Sometimes we want to pass arguments to new programs ls l cp foo bar In C programs: argc and argv argv[0] : name of the program argv[1] : first argument... argc : number of arguments argv[argc] = NULL : Required by the C standard Your task: put arguments on the stack when a program is loaded. Ex.echo: while( argc) printf( %s,*++argv); 46 Lab 3: Part B Arguments to the syscall are passed via user program stack Program arguments are passed in a similar fashion The top of the user stack will contain these arguments for the duration of the program 47 Lab 3: PB: Preparatory Steps (1) Lab 2::STEP 3 into userprog/process.c, find setup_stack() *esp = PHYS_BASE; CHANGE IT BACK! change to *esp = PHYS_BASE - 12; Before continuing, explain why you have "KERNEL PANIC" after you have removed "-12". What is wrong and why did the program work before? Hint the C lib wraps main: /* src/lib/user/entry.c */ void _start (int argc, char *argv[]) { exit (main (argc, argv)); 48
9 Lab 3::PB::Preparatory Steps (2) The user program with arguments should be called with single quotes ('...') from the Pintos command line: pintos --qemu -- run nasty_program arg1 arg2 arg3 program with arguments via syscall exec("nasty_program arg1 arg2 arg3"); Lab 3: PB: Implementation (1) STEP 1: Break the string in to parts Use strtok_r() lib/string.[ch] STEP 2: Put it on the stack Necessary details about setting up the stack for this task you can find in Program Startup Details section of Pintos documentation. Lab 3 : Pointer paranoia Memory validation (simple method) VM Physical Memory PHYS_BASE A valid pointer into a syscall: 0 is below PHYS_BASE in VM Page directory is associated with a page of physical memory: use pagedir_getpage() Kill the user program if there is an error! Lab 3 : Pointer paranoia Memory validation (tricky method) VM Physical Memory PHYS_BASE 0 Page directory Another way to validate memory is mentioned in the manual Check that the pointer is below PHYS_BASE Dereference the pointer (*ptr) and then take care of page faults This is how it is done in real operating systems, it is faster Suggestion: Only do it this way if you want the extra challenge 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 0xbfffffd Type char[5] char[5] char[5] char[14] char * char * char * char * char * char ** int void (*) () 53 exit code -1 Lab3 : Testing When Part B is finished you can run gmake check The following tests Lab 2: halt, exit, create-normal, create-empty, create-null, create-long, create-exists, createbound, open-normal, open-missing, open-boundary, open-empty, open-twice, close-normal, close-stdin, close-stdout, close-bad-fd, read-boundary, read-zero, read-stdout, read-bad-fd, write-normal, write-boundary, write-zero, write-stdin, write-bad-fd Most of the exec-* and wait-* tests (and lab2) should pass when you have finished Part A&B Run a single test (from userprog/build): gmake tests/userprog/halt.result The rest when Part C is finished (around 60 tests in total) 51 54
10 Lab 3 : Part C Lab 3 : Pointer paranoia A trickier user program Part C: Nothing a user-program does should cause the kernel to crash, panic or fail an assertion! Make the kernel robust to ill-behaving user programs! Example evil user program passes NULL for filename: create( (char *) 0, 1); Or worse, writing to kernel space: write( STDIN_FILENO, 0xc , 666 ); Be paranoid All pointers from user programs into the kernel must be checked. PHYS_BASE VM Physical Memory stack pointer, string, buffer 55 exit code A valid pointer into a syscall: 0 is below PHYS_BASE in VM Page directory is associated with a page of physical memory: use pagedir_getpage() Kill the user program if there is an error! #define PGS 4096 /* page size */ #define PMASK 0xfffff000 static char inbss; int main (int argc, char ** argv) { char * bss_page = (char*) ((int)(&inbss) & PMASK); In this program, the beginning of the string is valid Just checking the pointer is not enough memset ( bss_page, 'a', PGS ); create (bss_page+pgs 5, 1024); ; 57 TDDB68 Extra slides test programs 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, 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, wait-bad-pid write-bad-fd 59 60
11 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); ; 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]); ; 61 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); ; 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. 62 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. 63 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. You may need to format the disk before.) 64
Laboratory work in TDDI04 Pintos Assignments 2, 3
Laboratory work in TDDI04 Pintos Assignments 2, 3 Viacheslav Izosimov 2008-01-28 viaiz@ida.liu.se Instead of Motivation The deadline for Lab 1 is extended to 1st of February! KERNEL PANIC!!! YOUR PINTOS
More informationTDDB68 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 informationLaboratory 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 informationTDDB 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 informationTDDB 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 informationTDDB 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 informationTDDB68 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 informationProject 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 informationTDDB68 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 informationUser 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 informationProject 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 informationProject 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 informationProject 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 informationCS 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 informationTDDB 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 informationPintos 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 informationPintos 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 informationTDDB68. 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 informationProject-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 informationProject #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 informationOperating 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 informationProcesses. 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 informationA 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 informationPebbles 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 informationSection 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 informationProject 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 informationby 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 informationCSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files
CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files ... and systems programming C basic syntax functions arrays structs
More informationCSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.
CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files... and systems programming C basic syntax functions arrays structs
More informationOutline. TDDC47 Lesson 1: Pintos labs Assignments 0, 1, 2. Administration. A new kind of complexity. The Pintos boot process
TDDC47 Lesson 1: Pintos labs Assignments 0, 1, 2 Jordi Cucurull, Mikael Asplund 2010 Administration Introduction to Pintos Scheduler Interrupts Synchronisation General description of labs Lab 1 Lab 2 Outline
More informationA2 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 informationCS 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 informationSYSTEM 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 informationSection 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 informationSection 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 informationCSC209 Review. Yeah! We made it!
CSC209 Review Yeah! We made it! 1 CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files 2 ... and C programming... C basic syntax functions
More informationThe Process Abstraction. CMPU 334 Operating Systems Jason Waterman
The Process Abstraction CMPU 334 Operating Systems Jason Waterman How to Provide the Illusion of Many CPUs? Goal: run N processes at once even though there are M CPUs N >> M CPU virtualizing The OS can
More informationCS140 Operating Systems Final December 12, 2007 OPEN BOOK, OPEN NOTES
CS140 Operating Systems Final December 12, 2007 OPEN BOOK, OPEN NOTES Your name: SUNet ID: In accordance with both the letter and the spirit of the Stanford Honor Code, I did not cheat on this exam. Furthermore,
More informationCSC369 Lecture 2. Larry Zhang
CSC369 Lecture 2 Larry Zhang 1 Announcements Lecture slides Midterm timing issue Assignment 1 will be out soon! Start early, and ask questions. We will have bonus for groups that finish early. 2 Assignment
More informationMon 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 informationCSci 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 informationCSC369 Lecture 2. Larry Zhang, September 21, 2015
CSC369 Lecture 2 Larry Zhang, September 21, 2015 1 Volunteer note-taker needed by accessibility service see announcement on Piazza for details 2 Change to office hour to resolve conflict with CSC373 lecture
More informationCS 537 Lecture 2 - Processes
CS 537 Lecture 2 - Processes Michael Swift 1 Basic Structure Kernel is a big program that starts when you boot your program Has full access to physical hardware. User programs, utilities, services see
More informationMidterm 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 informationOS 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 informationCS61 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 informationPRINCIPLES 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 informationMidterm Exam CPS 210: Operating Systems Spring 2013
Your name: Sign for your honor: Midterm Exam CPS 210: Operating Systems Spring 2013 The last page of this exam is a list of terms used in this class, and whose meanings you should know. You may detach
More informationUNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Fall Programming Assignment 1 (updated 9/16/2017)
UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Fall 2017 Programming Assignment 1 (updated 9/16/2017) Introduction The purpose of this programming assignment is to give you
More informationSOFTWARE ARCHITECTURE 3. SHELL
1 SOFTWARE ARCHITECTURE 3. SHELL Tatsuya Hagino hagino@sfc.keio.ac.jp slides URL https://vu5.sfc.keio.ac.jp/sa/login.php 2 Software Layer Application Shell Library MIddleware Shell Operating System Hardware
More informationAltering 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 informationControl 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 informationCS24: 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 informationUnix-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 informationCS 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 informationCSCE 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 informationProcesses & 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 informationAltering 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 informationOperating Systems (234123) Spring 2017 (Homework Wet 1) Homework 1 Wet
Homework 1 Wet Due Date: 30/4/2017 23:00 Teaching assistant in charge: Yehonatan Buchnik Important: the Q&A for the exercise will take place at a public forum Piazza only. Critical updates about the HW
More informationProcesses (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 informationProcess Management! Goals of this Lecture!
Process Management! 1 Goals of this Lecture! Help you learn about:" Creating new processes" Programmatically redirecting stdin, stdout, and stderr" Unix system-level functions for I/O" The Unix stream
More informationExceptional 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 informationProcess Management! Goals of this Lecture!
Process Management! 1 Goals of this Lecture! Help you learn about:" Creating new processes" Programmatically redirecting stdin, stdout, and stderr" (Appendix) communication between processes via pipes"
More informationKurt Schmidt. October 30, 2018
to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed
More informationCS 33. Architecture and the OS. CS33 Intro to Computer Systems XIX 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.
CS 33 Architecture and the OS CS33 Intro to Computer Systems XIX 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. The Operating System My Program Mary s Program Bob s Program OS CS33 Intro to
More informationCS 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 informationComputer Systems Assignment 2: Fork and Threads Package
Autumn Term 2018 Distributed Computing Computer Systems Assignment 2: Fork and Threads Package Assigned on: October 5, 2018 Due by: October 12, 2018 1 Understanding fork() and exec() Creating new processes
More informationProject 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 informationCPSC 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 informationProject 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 informationLinux shell scripting Getting started *
Linux shell scripting Getting started * David Morgan *based on chapter by the same name in Classic Shell Scripting by Robbins and Beebe What s s a script? text file containing commands executed as a unit
More informationAssignment 1. Teaching Assistant: Michalis Pachilakis (
Assignment 1 Teaching Assistant: Michalis Pachilakis ( mipach@csd.uoc.gr) System Calls If a process is running a user program in user mode and needs a system service, such as reading data from a file,
More informationExceptional 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 informationLast 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 informationWindows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.
Structure Unix architecture users Functions of the System tools (shell, editors, compilers, ) standard library System call Standard library (printf, fork, ) OS kernel: processes, memory management, file
More informationInterrupts, 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 informationProcesses. 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 information518 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 informationCS61 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 informationProcess Management 1
Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Programmatically redirecting stdin, stdout, and stderr (Appendix) communication between processes via pipes Why?
More information628 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 informationCSE 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 informationProcesses, Exceptional
CIS330, Week 9 Processes, Exceptional Control Flow CSAPPe2, Chapter 8 Control Flow Computers do Only One Thing o From startup to shutdown, a CPU simply reads and executes (interprets) a sequence of instructions,
More informationProcess 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 informationCSE 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 informationwww nfsd emacs lpr Process Management CS 537 Lecture 4: Processes Example OS in operation Why Processes? Simplicity + Speed
Process Management CS 537 Lecture 4: 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 informationFile Descriptors and Piping
File Descriptors and Piping CSC209: Software Tools and Systems Programming Furkan Alaca & Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Week 8 Today s topics File Descriptors
More informationGiving 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 informationExercise 1: Basic Tools
Exercise 1: Basic Tools This exercise is created so everybody can learn the basic tools we will use during this course. It is really more like a tutorial than an exercise and, you are not required to submit
More informationCS 5460/6460 Operating Systems
CS 5460/6460 Operating Systems Fall 2009 Instructor: Matthew Flatt Lecturer: Kevin Tew TAs: Bigyan Mukherjee, Amrish Kapoor 1 Join the Mailing List! Reminders Make sure you can log into the CADE machines
More informationProcesses. Processes (cont d)
Processes UNIX process creation image-file arg1 arg2 Shell command line example ls -l Equivalent to /bin/ls -l Why? How do you find out where the image file is? Background processes ls -l & Execute a process
More informationExceptional 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 informationUNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Summer 2016 Programming Assignment 1 Introduction The purpose of this
UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Summer 2016 Programming Assignment 1 Introduction The purpose of this programming assignment is to give you some experience
More informationOperating Systems, Assignment 2 Threads and Synchronization
Operating Systems, Assignment 2 Threads and Synchronization Responsible TA's: Zohar and Matan Assignment overview The assignment consists of the following parts: 1) Kernel-level threads package 2) Synchronization
More informationCS 470 Operating Systems Spring 2013 Shell Project
CS 470 Operating Systems Spring 2013 Shell Project 40 points Out: January 11, 2013 Due: January 25, 2012 (Friday) The purpose of this project is provide experience with process manipulation and signal
More informationCreating a Shell or Command Interperter Program CSCI411 Lab
Creating a Shell or Command Interperter Program CSCI411 Lab Adapted from Linux Kernel Projects by Gary Nutt and Operating Systems by Tannenbaum Exercise Goal: You will learn how to write a LINUX shell
More informationOS 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 informationC Review. MaxMSP Developers Workshop Summer 2009 CNMAT
C Review MaxMSP Developers Workshop Summer 2009 CNMAT C Syntax Program control (loops, branches): Function calls Math: +, -, *, /, ++, -- Variables, types, structures, assignment Pointers and memory (***
More informationOS COMPONENTS OVERVIEW OF UNIX FILE I/O. CS124 Operating Systems Fall , Lecture 2
OS COMPONENTS OVERVIEW OF UNIX FILE I/O CS124 Operating Systems Fall 2017-2018, Lecture 2 2 Operating System Components (1) Common components of operating systems: Users: Want to solve problems by using
More informationExceptional Control Flow Part I Oct. 28, 2009"
Exceptional Control Flow Part I Oct. 28, 2009" Control Flow" Time" Physical control flow" " inst 1 " inst 2 " inst 3 " " inst n " " 2! 3! Altering the Control Flow" Exceptional Control
More information