------------------------------------------------------ Lecture 02 - February 05, 2002 ------------------------------------------------------ AGENDA: 0 Admin 1 P1 - Command interpreter implementation 2 Ch. 1 highlights ------------------------------------------------------ 0 - ADMIN ------------------------------------------------------ Quiz #1 on Friday. ------------------------------------------------------ 1 - P1: COMMAND INTERPRETER IMPLEMENTATION ------------------------------------------------------ Ch 1.3 and 1.4 cover many relevant details. Be sure to do the reading! Discuss implementation of command interpreter (shell) * main( int argc, char *argv[] ) * Tanenbaum covers fork, but it's worth getting this right. Run "man fork" cpid = fork(); if cpid == -1 => oops, fork failed. Look out below if cpid == 0 => this is the child process if cpid > 0 => this is the parent process and cpid is the process id of the child * execvp( what_to_exec, new_proc_argv ) print an error message, then exit right below execvp - if execvp works, never reaches message and exit - if execvp fails, you DO NOT want the child process to stay alive and start acting like the parent. That's the situation that leads to great unhappiness. * Tanenbaum discusses waitpid and gives examples p. 24, fig 1-10; p. 25 Go through samples in the p1 dir & discuss coding style and the use of seatbelts when doing system programming. When it comes to grading, I want to see that you check EVERY system/library call for possible failure. ------------------------------------------------------ 2 - CH. 1 HIGHLIGHTS ------------------------------------------------------ multiprogramming: 1st step toward timesharing spooling: manage I/O transfers by collecting data in a file while other things continue to run on the system timesharing: multiple users with on-line terminals MULTICS: grandparent of pretty much all modern O/S's. Version 7 UNIX: one of the first major widely-used versions of UNIX POSIX: a POrtable Standard for unIX (or something like that -- it's been a long time) that was meant to make it possible for all UNIX clones to be compatible in all the important aspects LINUX: the product of enthusiastic people who wanted to make MINIX "bigger and better (well, at least bigger)" (p. 15). address space: a list of memory locations available to a process core image: an image of a process signal: a message that causes a process to put everything on hold and run a special signal-handling procedure. What happens depends on the signal and the programming. Try "kill -l" to list signals available on a UNIX system. UID: user id super-user: system omnipotent account root directory: top level directory rwx bits: do an "ls -l" to demonstrate briefly file descriptor: discuss root file system: fig 1-7 p. 19 special files: block special files, character special files pipe: pseudofile buffer that allows processes to write to each other system calls: look through fig 1-9 p. 23 COS 421 - Lecture Notes #2 SPRING 2003 COS421-lect-2003-02-05.doc Page 2 Printed 05.02.03