II. Systems Programming using C (Process Control Subsystem)

Size: px
Start display at page:

Download "II. Systems Programming using C (Process Control Subsystem)"

Transcription

1 II. Systems Programming using C (Process Control Subsystem) 129

2 Intended Schedule Date Lecture Hand out Submission Introduction to Operating Systems Course registration Systems Programming using C (File Subsystem) 1. Assignment Systems Programming using C (Process Control) 2. Assignment 1. Assignment Processes Scheduling 3. Assignment 2. Assignment Process Synchronization 4. Assignment 3. Assignment Inter Process Communication 5. Assignment 4. Assignment Pfingstmontag 6. Assignment 5. Assignment Input / Output 7. Assignment 6. Assignment Memory Management 8. Assignment 7. Assignment Assignment 8. Assignment Filesystems Assignment 9. Assignment Special subject: Transactional Memory 10. Assignment Special subject: XQuery your Filesystem Wrap up session First examination date Second examination date 130

3 Process Control Subsystem 131

4 !"#$%"& *+%,-.('#")-/ UNIX system architecture (System V)!"+5#<"$=$;6$1))" -."#&'"("%!"#$"%&'"("% :$;6$1))&%&A%;#?"D.('#")15E$5E4.>?+%##'#"AA"-8.3.4"5&8*%%&0$4"#/*8"9 71#"%4.5&'('#")-8/0%"& "59 B+#"$4:$;<"''4 C;))5+%D1#%;+ 8;<=9 Files :5EE"$ //"#&8*89"9 :$;<"'''#"5"$5+6'4.5&'('#")-86#78".. 87$4#7%& "59 :$;<"'';$4 <5#"%A "+1%0$:9 Processes 85"57#3 5*$*:"5"$49 01$231$"4.#"5"$5+6!"#$"%&'"("% )*#+,*#"&'"("% 01$231$"!"#$%&'()*&+,*(-.)/ 132

5 Program and Processes A program is an executable file residing on disk in a directory read into memory executed by the kernel as a result of one of the six exec(3) functions. An executing instance of a program is called a process. Every process has a unique numeric identifier called process ID. The process ID is always a non-negative integer. Although unique, process ID are reused (kernel delays re-usage). 133

6 Running process printing pid 134

7 Status information of processes man 1 ps describes the user command program /bin/ps 135

8 Obtaining process state with ps(1) 136

9 Getting process identifiers 137

10 Virtual Memory Each process has its own address space in virtual memory. Processes: do not know about each other (from their perspective) run alone on the machine their address spaces are independent from each other For inter-process communication special kernel mechanisms have to be invoked ( lecture 5) 138

11 Virtual Memory on Linux Memory locations are addressed through pointers. As such the natural word size of a processor sets an upper bound for the largest address to reference. On 32-bit systems: 2 32 Bytes = Bytes = 4 GiB Often this exceeds the physical memory available and gives name to the term virtual memory. Linux divides virtual memory in kernel and user space. Each user process has its own address space from 0 to TASK_SIZE. TASK_SIZE depends on architecture. kernel space user space 2 32 / 2 64 TASK_SIZE 0 139

12 Building programs 140

13 From source to executable code From Source Code To Executable Code Translation Steps (multi-phase compilation) Compilation HLL source code to assembler source code Assembly Assembler source code to object code Linking Object code to executable code Compilers and assemblers create object files containing the generated binary code and data for a source file. Linkers combine multiple object files into one, loaders take object files and load them into memory. Goal: An executable binary file (a.out) From high-level language (HLL) source code to executable code, i.e., concrete processor instructions in combination with data

14 Translation step using gcc(1) Translation Steps Using gcc(1) Quellcode C/C++ Assembler-Quellcode Objektdatei, Bibliotheksdatei Eingabedateien *.c/*.cc/*.cpp *.s *.o/*.a Präprozessor Compiler Assembler Binder Ausgabedateien *.i/*.ii *.s *.o a.out Vorverarbeiteter C/C++-Quellcode Assembler-Quellcode Objektdatei Ausführbare Datei (ungebunden) (= Objektdatei, ladbar)

15 Creation of an executable file Creation Of An Executable File (Filename).c Kompilieren gcc (Filename).s = Operation = Kommando = Eingang oder Ausgang Assemblieren gas Object/Library Files (Filename).o ld Binden a.out

16 Linking an executable binary Linking An Executable Binary OBJ1 OBJ2 OBJ3.text1.data1.bss1.text2.bss2.text3.data3.bss3 Eingabedaten: ungebundene Objektdateien Bindung (linking).text: Code.data: initialisierte Variablen.bss: nicht initialisierte Variablen OBJtotal.text1.text2.text3.data1.data3.bss1.bss2.bss3 Verarbeitungsresultat: ausführbare Datei (gebunden, reloziert) Each object code (compiled seperately) starts at address 0 Linking them together involves centralization of sections relocation of adresses

17 Program file organization Typical Program Organisation A typical program divides naturally in sections Code machine instructions, should be unmodifiable, size is known after compilation, does not change (.text) Data static data initialized (.data) /uninitialized (.bss) constant address in memory permanent life time dynamic data stack or heap storage space not known volatile life time

18 Memory Layout 146

19 (Virtual) Memory Layout Virtual Memory And Segments Virtual Memory Whenever a process is created, the kernel provides a chunk of physical memory which can be located anywhere Through the magic of virtual memory (VM), the process believes it has all the memory on the computer ( lecture 8) Typically the VM space is laid out in a similar manner: Text Segment (.text) Initialized Data Segment (.data) Uninitialized Data Segment (.bss) The Stack The Heap

20 { Memory Segments (TASK_SIZE) 148

21 Memory segments Memory Segments Text Segment. The text segment contains the actual code (including constants) to be executed. It s usually sharable, so multiple instances of a program can share the text segment to lower memory requirements. This segment is usually marked read-only so a program can t modify its own instructions. Initialized Data Segment. This segment contains global variables which are initialized by the programmer. Uninitialized Data Segment. Also named.bss (block started by symbol) which was an operator used by an old assembler. This segment contains uninitialized global variables. All variables in this segment are initialized to 0 or NULL pointers before the program begins to execute

22 Memory segments Memory Segments (cont.) The Stack The stack is a collection of stack frames which we will discuss later. When a new frame needs to be added (as a result of a newly called function), the stack grows downward. The Heap Dynamic memory, where storage can be (de-)allocated via C s free(3)/malloc(3). The C library also gets dynamic memory for its own personal workspace from the heap as well. As more memory is requested on the fly, the heap grows upward

23 Loading into memory segments Variable Placement Variables (outside a function) Globally declared variables go to the Uninitialized Data Segment if they are not initialized, to Initialized Data Segment otherwise. Necessary for the OS to decide if storage has to be loaded with initialization data from the executable binary. Variables (inside a function) Implicit assumption of auto, go to The Stack. Declared as static, see above. Constants (const) Text Segment Function Parameters Are pushed on The Stack or stored in registers. If pointers are passed, data is elsewhere

24 Variable placement, life time, visibility Variable Placement And Life Time (Code) int a; /* Permanent life time */ static int b; /* dito, but reduced scope */ void func ( void) { char c; /* only for the life time of func() */ /* but 2x; visible only in func() */ static int d; /* i m unique, exist once at a stable */ /* address, visible only in func() */ } int main ( void) { int e; /* life time of main() */ } int *pi = ( int*) malloc ( sizeof( int )); /* newborn */ func (); func (); free (pi ); /* RIP, pi points to an invalid address */ return (0);

25 Variable placement in address space Variable Placement And Life Time (Diagram) Adresse 0 PC(t=0) PC(t=x) pi 1. Instruktion 2. Instruktion 3. Instruktion 4. Instruktion... a b d int Code Daten Halde (Heap) SP(t=x) SP(t=0) max. c pi e Stapel (Stack) t=0: Programmausführung wird gestartet, d.h., Ausführungsumgebung ist bereits initialisiert t=x: beliebiger Zeitpunkt während der Programmausführung

26 Multitasking 154

27 Multitasking Systems In terms of hardware parallelism as much processes may be executed concurrently as processors are available. Multitasking systems allow for (apparently) simultaneous execution of multiple processes on a single processor. The kernel switches between processes in short intervals to simulate the parallel execution (task switch). The kernel decides in what way the computing time is assigned to different processes (scheduling lecture 3). 155

28 Processes and Threads Threads: Parallel running activities inside a process. Each thread belongs to dedicated process !9 7:9 Single Process 7<)32173()*+255 7<)32173()*+255.2C)2)23()*+2552 Multiple Processes 7;9.2C)2)23()*+2552 Single Control Flow 7<)3%3MC)2">.2C)2)23MC)2">5 Three Control Flows (Threads) Single Control Flow 8237<)32173MC)2"> Multiple Control Flows (Threads) 823.2C)2)23MC)2">5!"#$%$&'(")()*+,-. /*01234

29 Pseudo parallel execution!"#$%"&''('#")"!"%'*%"+,-.$,/"0$*$12$3))&"#$%"& Conceptually: Each process has its own machine -."+),//'012'.*' ,4$16"'',7, ,4$16"'',:,845:9 45,4$16"'',;,845;9 45,4$16"'',<,845<9 4$16"''?)> task switch 45D,4$12$3))> 6E0+"$,8!"#$"%&'(#)*+,"9 PC: program counter PCB: Process Control Block ",%/'012'.*' ,4$16"'',7 45,4$16"'',: 45,4$16"'',; 45,4$16"'',< 45,4$16"'',7 45,4$16"'',:?'AB CCD3E2F: ()*+2;;23G!"#$"%&'()*+,-."!!"!H E=>0:;;-*0A2):6A26Q !"#$%$&'(")()*+,-. /*01234 ="%# time time ="%# 4$16"'',7 4$16"'',: 4$16"'',; 4$16"'',< Time-Multiplexing

30 !"#$%"&''('#")" Task Switch and PCB *$+,"''-)'./01#-23"24-254*6! *$+,"''47 *$+,"''48 *64%24:*67;4'%./"$24 :*68;4%24*64<+=%"$"24 *$+,"''41>-?#42%./# :*67;4%24*64<+=%"$"24 *64%24:*68;4'%./"$24 :*67;B4:*68;A4C%$#-"11"4*6 5"$4*$+,"''"474D48 9"%# *674D4*684'%254%24*6!74D *6!84"2#/01#"2 *6!A4*$+."''46+2#$+14!1+.< :*$+,"''C"$E01#-23'50#"2;!"#$%$&'(")()*+,-. Glatz 2005 /*

31 Process Life Cycle!"#$%"&''('#")" *&+,-./0,'"12"%1"'23$45"''"' 56"713892:2;7#<"72;=321;273()* "A2;3A273()*C)"..73DE39"A2#<"72F G?")?2;3A273()*C)"..73DE3G?")?#<"72F ()*C)"..":0"6-3DE3H2?)12:7#<"72F ()*C)"..:22;A1C6;C3DE3I2).1;12)6;C7#<"72F 6&7"8#9,#"%.4$),# "67-K<):")2;3J"?213":C202C?371;A MMN3U1;3:27?1..?273H2?)12:77Q7?2.3!21;321;3*A2)3.2<)2)23/*)."?236;?2)7?K?+2; kann!"#$%$&'(")()*+,-. /*0123%4 159

32 Process Termination 160

33 Process Termination!"#$%"&''('#")" *$+,"''#"$)%-%"$.-/ /*).25362)3()* :59; <$=3A*)+21B1923?225619: !"B"7B)*#D"02.3/2D02)32)!"55B36:)CD3 >?;3IJ:-197B2)3/"00;3<%=3>*)."023?225619:

34 Eight way for a process to terminate Normal termination Returning from main Calling exit(3) Calling _exit(2) (POSIX.1) or _Exit(3) (ISO C) Return of the last thread from its start routine Calling pthread_exit(3) from the last thread Abnormal termination Calling abort(3) Receipt of a signal ( lecture 5) Response of the last thread to a cancellation request 162

35 Normal termination details Normal termination Returning from main Equivalent to calling exit(3) Calling exit(3) closes/flushes all standard I/O streams calls all exit handlers registered with atexit(3) ISO C does not deal with file descriptors, multiple processes (parents and children), and job control, as such its definition is incomplete for UNIX systems. 163

36 Normal termination details Calling _exit(2) (POSIX.1) or _Exit(3) (ISO C) ISO C defines _Exit(3) to provide a way for a process to terminate without exit or signal handlers. Whether standard I/O streams are flushed is system dependent. On UNIX systems _exit(2) and _Exit(3) are synonymous and do not flush standard I/O streams. The _exit(2) function is called by exit(2) and handles the UNIX system-specific details Return of the last thread from its start routine The return value of the thread is not used as the return value of the process. When the last thread returns, the process exits with 0. Calling pthread_exit(3) from the last thread Same as above 164

37 Starting and terminating a C program 165

38 Process Creation 166

39 Process Creation *+,+,-.$/0"''"$0" "$)%3%"$132!"#$%"&''('#")" A0023()* B19:12)263>*63A6-"6<3"63C6D30"C-2632E1<F3D,5,39*0"6<23489:2.30GC-: ()*+29923E2)D263H213I2D")-32)+2C<:3C6D3<202<26:01753E12D2)3:2).1612): ;%?3489:2.9:"):3;L61:1"01912)C6<? ;&?3489:2."C-)C-3+C)3()*+2992)+2C<C6<3DC)7531)<26D "C-26D263()*+299 ;$?3I26C:+2)"6-*)D2)C6<3+C.34:"): C263()* ;A##01!":1*699:"):? ;M?3AC90J9C6< :"#20"C-:)"<93;#,(23%41#?!"#$%$&'(")()*+, /*0123%&

40 What is a process?!"#$%"&''('#")" *+',%'#,"%-,.$/0"''1 >A()*:)"..B38,6,3main()A/C;!71*; H"72;E2)21563=1;!0,347"5!3C;83I2"#? ()*:)"..5*82E2)2156 H"72;97)C!7C)3+C)3()*+2992J2)<"07C;:38C)5638"93 D27)12E99F972.3=!"#$%!&'()**%"'+,&'-%#-'(./$%01#1 2%!34%5!&'0)**.)++6+7/ 2%8.,6)--)&%!&'0)**06*,9+: 2%!&'0)**.'+,);, kernel space 232 / 2 64 PCB user space argv, env ()*+299A 5*82 ()*+299A 8"72; (>D G8)299)"C. TASK_SIZE linux/sched.h: struct task_struct 0 168

41 Process Hierarchy 169

42 !"#$%"&''('#")" *+,+-./$01"''2%"$3$42%".5!"%'6%"78.9:%;< UNIX process hierarchy /=>?A %:%# B"##( B"##( B"##( '2 B"##( C%:D '2!"#$%$&'(")()*+,-. /*0123$$ 170

43 UNIX system start (simplified) Bootstrap loads system code to memory. Initialization of internal kernel data structures. Mount root filesystem Environment for the first process is created. System code becomes process with PID=0 Process 0 forks and creates process 1 (kernel space) Process 1 creates environment in user space and turns over PID=0 (kernel space), PID=1 (user space) 171

44 UNIX system start (simplified) Process 1 uses exec on, e.g., /sbin/init & becomes init init is responsible for bringing up a UNIX system after the kernel has been bootstrapped. It usually reads system-dependent initialization files (such as /etc/rc* or /etc/inittab, /etc/init.d) and brings the system to a certain state, such as multiuser. For instance, the terminals for users to login (getty) are started. It is a normal user process running with superuser privileges. init never dies. Meanwhile, process 0 starts kernel services in kernel space and finally becomes the swapper, i.e., the scheduler process. 172

45 Process Hierarchy on Linux Linux has a hierarchical process schema, i.e., each process is connected to its parent process. The kernel starts init as first process. The process hierarchy is a result of the process creation used on UNIX systems: fork(2) exec(3) family 173

46 Process creation and joining *$+,"'''#-$#.+$)"/ 3456*$+,"''0"$7"##2/1 3!56*$+,"''0"$1-&"82/1 3956*$+,"''"$,"212/1!"#$%"&''('#")" 45"16 -*)! 4)2"72 *$+,"''0"$"%/%12/1'.+$)"/ 3:56*$+,"''0"$"%/%12/1 3;56*$+,"''#$".."/ 8* :" Operating!"#$%$&'(")()*+,-. Systems Prof. Dr. Marc H. Scholl DBIS U KN Summer Term 2009 /*0123%$ 174

47 Related system calls!"#$%"&''('#")" *('#")+,-$,-".-/$.0$12"''3456$"+73*#+$# B6+%9 exec() $C fork() B$"+#" 5 pthread_create() CreateProcess() CreateThread() *('#")+,-$,-".-/$.0$12"''3456$"+738"$"%9%:,9: D1%9 wait()63waitpid() pthread_join() 5 5 A+%# 5 5 WaitForSingleObject() WaitForSingleObject()!"#$%$&'(")()*+,-. /*0123%4 175

48 Initialization of processes/threads!"#$%"&''('#")" *"%#"$+,&"-./0-1,#"0-,0-0"2"-3$/4"''"567$",8' !21:2;< H21D#12023!*;!)2:2)3C.#02.2;:12)?;72;31;3H2:)12>DDID:2.2;< 90%:;3$/4"''" 3<=>?;67$",8' 3$/4"''" A"$"$&20+ fork() J CreateProcess() J >0#"$B$/4C/)D popen() J J J 67$",8' >0%#%,EB,$,)D J pthread_create() J CreateThread() 176

49 Inheritance with fork / exec *+,+-./"$"$&012.01#"$.3$45"''"1!"#$%"&''('#")" /"$"$&012.&"%.61%783$45"''" /*)!1567 <"=2192A!)1#=*)25B39123C*53D0=2)5#)*+2AA3E2+*625 F21=2)23D1625AGH"-=25B3+,4,3:A2)I6)*:#319B3J.62E:56AC")1"E025B3K)E21=AC2)+21GH51AB ;*5=)*00=2).15"03:AL, H" (M<3:593((M< <"=2192A!)1#=*)25B39123!/"0)1"*1)2)!351GH=362A2=+=3H"E25 F21=2)23D1625AGH"-=25B3+,4,3:A2)I6)*:#319B3J.62E:56AC")1"E025B3K)E21=AC2)+21GH51AB ;*5=)*00=2).15"03:AL, Operating!"#$%$&'(")()*+,-. Systems Prof. Dr. Marc H. Scholl DBIS U KN Summer Term 2009 /*0123$% 177

50 Forking processes 178

51 *+,+*-.$/0"''"-12#"$-32%45-.$/0"''6"$78&"9127-:;/$<%27=!"#$%"&''('#")" ()1:+1#8215#120D int main() { int k, status; pid_t pid; k=fork(); if (k == 0) {... // Anweisungen, die nur Kindprozess } Forking processes on UNIX... // ausführen soll exit(0); // Kindprozess terminiert } else {... // Anweisungen, die nur Elternprozess... // ausführen soll pid = wait(&status); // Auf Ende des Kindprozesses warten exit(0); }!"#$%$&'(")()*+,-. /*0123%4 179

52 Forking processes on UNIX!"#$%"&''('#")" *$+,"''-"$./&" *$+,"''-"$5+66"012.37/&38+$9:;18$18< =0#"$26$+,"'' >%256$+,"'' *$%2,%6/&0/18 main() { int k, status; pid_t pid; main() { int k, status; pid_t pid; k=fork(); if (k == 0) { exit(0); } else { pid = wait(&status); } } k=fork(); if (k == 0) { exit(0); } else { pid = wait(&status); } } -*)! #")286 9:10; 5" !"#$%$&'(")()*+,-. /*0123%4 180

53 Process system calls in a nutshell *+%,-.('#")/01$01"213$24$56"''"$6" "$)%+%"$0+7!"#$%"&''('#")" system call pid = fork () pid = wait (&statloc) pid = waitpid (pid, &statloc, options) s = execve (name, argv, environp) exit (status) 42567)2189:;3<!"#$%&'()*+,$+)&-&$./)0$1(/2(*$3(4&+= +9)D6!E3-"0053/2702)B3A"::3FD6!;"82G2)?3H%= >)52?+?30"9-2:A2:3()*+2553A9)67321:2:3:292:3()*+2553<:292)3()* )8?3O*:3"0?2.3()*+255=,3<P18?3H%38213/2702)3+9)D6!B35*:5?3!21:23FD6!H ;"82= Q67?9:;R3253;18?3S302167?3O2)56712A2:23T")1":?2:3A125253UV5?2."9-)9-5W J2).1:12)?3"9-)9-2:A2:3()*+25539:A35?200?3FD6!;"82G2)?3-D)342?)12855VH 5?2.382)21?3<G1)A3D82)3wait() /3waitpid()3A2.3>0?2):#)* ;M:;01673;2."67?=!"#$%$&'(")()*+,-. /*0123&& 181

54 The fork(2) system call PID is returned to parent, because a process can have more than one child, and there is no function that allows a process to obtain the PID of its children. Returning 0 to the child is apt, since PID=0 is reserved by the kernel, so it s not possible for 0 to be the PID of a child. The child can always obtain the PID of its parent, calling getppid(2). 182

55 !""*+%,-*,'./-*+/0-'123$-*,''#4#-'!"#$%"&''('#")" 92>263:100D 41232)?"0;263:1) I6-*).";1*6263A*.3JK7;2.3+B927;200;L FFM );23!*.>1612);3A1"3N7;";0*COF(")".2;2)35273wait()Pwaitpid()FEB-)B-7 FFM3N7;";B7O3!"663.1;;2073A*) );2)3R"!)*73"B792:2);2;3:2)526< 33333WIFEXITED(status)<3STUV3-H)36*)."0W3/EXJV3-H)3A*)+21;193">92>)*C? #120< Obtaining termination status pid_t pid; int status; pid = wait(&status); if (WIFEXITED(status)) printf( Rückgabewert ist %d\n, WEXITSTATUS(status);!"#$%$&'(")()*+,-. /*0123&$ 183

56 Zombie Processes!"#$%"&''('#")" *$+,"'''#-$#.)%#./"$,0"%1"2.34+)&%"5*$+&6")7 = :35062)7#)*+28839") !7:3:17;#)* ).1712)6<3 "E-357;23;283:17;#)* >2F*)35062)7#)*+28839")626 ( C ( C ( C ( C fork() ( C ( D ( C fork() ( ( C ( D D ( C ( D exit() exit() B"627A wait() =*.>12? #)* !"#$%$&'(")()*+,-. /*0123%4

57 Zombie prevention *+)&%","$-%./"$0.12)%##"3'24.5"36$+7"'' G%H G&H G$H GIH GKH fork() 91:;% 91:;% 91:;% wait()j exit() fork() 91:;& 91:;& 91:;& /*0123&4 185

58 Process chaining 186

59 Process chaining!"#$%"&''('#")" *$+,"''#-$#.)%#./"$0"## %2% ": <"%# /"$0"##123 * = * = ;-#"2: execve() *! *! 187 /*0123&%

60 exec(3) family ok = execl(pathname, arg0, arg1,..., NULL); Zweck: Startet ausführbare Datei als neuen Prozess, ersetzt (terminiert) damit laufenden Prozess Parameter: const char * pathname: Pfadname der Datei const char * arg0, * arg1,..: 1./2./.. Kommandozeilenargumente (Liste mit NULL abschließen) Rückgabewert int: keine Rückkehr falls okay; im Fehlerfall Rückgabe von -1 ok = execle(pathname, arg0, arg1,..., NULL, envp[]); Zweck: Startet ausführbare Datei als neuen Prozess, ersetzt (terminiert) damit laufenden Prozess Parameter: const char * pathname: Pfadname der Datei const char * arg0, * arg1,..: 1./2./.. Kommandozeilenargumente (Liste mit NULL abschließen) const char * envp[]: Adresse einer neuen Umgebungsvariablenliste Rückgabewert int: keine Rückkehr falls okay; im Fehlerfall Rückgabe von -1 ok = execlp(filename, arg0, arg1,..., NULL) Zweck: Startet ausführbare Datei als neuen Prozess, ersetzt (terminiert) damit laufenden Prozess Parameter: const char * filename: Dateiname (Suchpfad entsprechend Umgebungsvariable PATH) const char * arg0, * arg1,..: 1./2./.. Kommandozeilenargumente (Liste mit NULL abschließen) Rückgabewert int: keine Rückkehr falls okay; im Fehlerfall Rückgabe von -1 ok = execv(pathname, argv[]); Zweck: Startet ausführbare Datei als neuen Prozess, ersetzt (terminiert) damit laufenden Prozess 188

61 ok = execlp(filename, arg0, arg1,..., NULL) Zweck: Startet ausführbare Datei als neuen Prozess, ersetzt (terminiert) damit laufenden Prozess Parameter: const char * filename: Dateiname (Suchpfad entsprechend Umgebungsvariable PATH) const char * arg0, * arg1,..: 1./2./.. Kommandozeilenargumente (Liste mit NULL abschließen) exec(3) family Rückgabewert int: keine Rückkehr falls okay; im Fehlerfall Rückgabe von -1 ok = execv(pathname, argv[]); Zweck: Startet ausführbare Datei als neuen Prozess, ersetzt (terminiert) damit laufenden Prozess Parameter: const char * pathname: Pfadname der Datei const char * argv[]: Adresse einer Liste mit allen Kommandozeilenargumenten Rückgabewert int: keine Rückkehr falls okay; im Fehlerfall Rückgabe von -1 ok = execve(pathname, argv[], envp[]); Tab. 3 5 Unix-Systemaufrufe execl(), execle(), execlp() und execv() Zweck: Startet ausführbare Datei als neuen Prozess, ersetzt (terminiert) damit laufenden Prozess Parameter: const char * pathname: Pfadname der Datei const char * argv[]: Adresse einer Liste mit allen Kommandozeilenargumenten const char * envp[]: Adresse einer neuen Umgebungsvariablenliste Rückgabewert int: keine Rückkehr falls okay; im Fehlerfall Rückgabe von -1 ok = execvp(filename, argv[]); Zweck: Startet ausführbare Datei als neuen Prozess, ersetzt (terminiert) damit laufenden Prozess Parameter: const char * filename: Dateiname (Suchpfad entsprechend Umgebungsvariable PATH) const char * argv[]: Adresse einer Liste mit allen Kommandozeilenargumenten Rückgabewert int: keine Rückkehr falls okay; im Fehlerfall Rückgabe von -1 Tab. 3 6 Unix-Systemaufrufe execve() und execvp() 189

62 Differences among the exec functions 190

63 main function 191

64 Program Startup The main function Prototype for the main function The function called at program startup is named main It shall be defined with a return type of int And either with no parameters: int main ( void); Or with two parameters: int main ( int argc, char * argv []); 192

65 Constraints For main Function Constraints of main function Terminology (though any names may be used) argc stands for argument count argv stands for argument vector If argc and argv are declared The value of argc shall be nonnegative argv[0] represents the program name or argv[0][0] shall be the null character if the program name is not available argv[1] to argv[argc-1] represent program parameters argv[argc] shall be a NULL pointer 193

66 Command-line Arguments main: Argument vector When a program is executed, the process that does the exec can pass command-line arguments to the new program Normal operation for UNIX system shells argv: NULL echo\0 hello,\0 world\0 194

67 Environment Environment Each program is also passed an environment list Like the argument list, it is an array of character pointers Each pointing to a null-terminated C string The address of the array is contained in a global variable: extern char ** environ ; environ: NULL HOME=/home/holu\0 SHELL=/bin/ksh\0 PS1=\w \$\

68 Environment (cont.) Environment (cont.) Terminology environ is called environment pointer The array of pointers is the environment list The strings they point to are the envoronment strings By convention, name=value string are used Historical third argument to main (not ISO C) int main ( int argc, char * argv [], char * envp ); Most UNIX systems have provided a third argument to main ISO C specifies main with two arguments Posix.1 specifies environ to be used instead of 3rd arg

69 Echo Command-line Arguments Echo command-line arguments # include <stdio.h> int main ( int argc, char * argv []) { int i; /* for (i = 0; argv[i]!= NULL; i ++) */ for ( i = 0; i < argc ; i ++) printf (" argv [%d]: %s\n", i, argv [i ]); } return (0); $./a. out -a 1 -arg2 -- arg3 argv [0]:./a. out argv [1]: -a argv [2]: 1 argv [3]: -arg2 argv [4]: -- arg

70 Building a shell 198

71 (Very) basic sketch of a shell *+,+-./012#%31'4"%'".5"$.61%789:";; int main () { char kdo[100]; pid_t pid; int status;!"#$%"&''('#")" } while(1) { printf("$>"); gets(kdo); pid = fork(); if (pid==0) execl(kdo,null); else wait(&status); } /*0123&4 199

72 How a shell (basically) works... *+,-#%.,'/"%'"01"$023" *.."9:*19;2)#)2;2)373()*+2<<31.3=29>;+2).*:><!"#$%"&''('#" BOE3/"00<391D6;3B$EF35!)1#;:";21J 200

73 *+",,-./0'12+$&3$".43#"%.'#3$#"5 56")637*)82)9):;8#)*+2<<= Start up of an executable!"#$%"&''('#")" 8:9 8=9 8?9 '+!"#$%& '+!"#$%& '+!"#$%& 16$789 '+ '()*+ '()*+ ;)< ">";.;)< /*0123&4 201

74 Next lecture: Next lecture/tutorial slots Process Scheduling Mo, , 12:00-14:00, C 252 (new room!) Next tutorial: Introduction to the C Programming Language Part II Tomorrow, Tue, , 16:00-18:00, C 252 Slides: arbeitsgruppen/dbis/lehre/operating-systems/ Have fun and see you next week! 202

Computer Systems II. Unix system calls. fork( ) wait( ) exit( ) How To Create New Processes? Creating and Executing Processes

Computer Systems II. Unix system calls. fork( ) wait( ) exit( ) How To Create New Processes? Creating and Executing Processes Computer Systems II Creating and Executing Processes 1 Unix system calls fork( ) wait( ) exit( ) 2 How To Create New Processes? Underlying mechanism - A process runs fork to create a child process - Parent

More information

Content. Introduction and History. File I/O. The File System. Shell Programming. Standard Unix Files and Configuration. Processes

Content. Introduction and History. File I/O. The File System. Shell Programming. Standard Unix Files and Configuration. Processes Content Introduction and History File I/O The File System Shell Programming Standard Unix Files and Configuration Processes Programs are instruction sets stored on a permanent medium (e.g. harddisc). Processes

More information

CSI 402 Lecture 13 (Unix Process Related System Calls) 13 1 / 17

CSI 402 Lecture 13 (Unix Process Related System Calls) 13 1 / 17 CSI 402 Lecture 13 (Unix Process Related System Calls) 13 1 / 17 System Calls for Processes Ref: Process: Chapter 5 of [HGS]. A program in execution. Several processes are executed concurrently by the

More information

C programs in (address) space and (run-)time. Systems Programming. C, assembler, and machine code. Where is my data and why do I have to know?

C programs in (address) space and (run-)time. Systems Programming. C, assembler, and machine code. Where is my data and why do I have to know? 3 4 C programs in (address) space and (run-)time Systems Programming 02. C Programs in Space and Time Alexander Holupirek Database and Information Systems Group Department of Computer & Information Science

More information

ELEC 377. Operating Systems. Week 1 Class 3

ELEC 377. Operating Systems. Week 1 Class 3 Operating Systems Week 1 Class 3 Last Class! Computer System Structure, Controllers! Interrupts & Traps! I/O structure and device queues.! Storage Structure & Caching! Hardware Protection! Dual Mode Operation

More information

Libmonitor: A Tool for First-Party Monitoring

Libmonitor: A Tool for First-Party Monitoring Libmonitor: A Tool for First-Party Monitoring Mark W. Krentel Dept. of Computer Science Rice University 6100 Main St., Houston, TX 77005 krentel@rice.edu ABSTRACT Libmonitor is a library that provides

More information

Chapter 6, The Operating System Machine Level

Chapter 6, The Operating System Machine Level Chapter 6, The Operating System Machine Level 6.1 Virtual Memory 6.2 Virtual I/O Instructions 6.3 Virtual Instructions For Parallel Processing 6.4 Example Operating Systems 6.5 Summary Virtual Memory General

More information

1 Posix API vs Windows API

1 Posix API vs Windows API 1 Posix API vs Windows API 1.1 File I/O Using the Posix API, to open a file, you use open(filename, flags, more optional flags). If the O CREAT flag is passed, the file will be created if it doesnt exist.

More information

System Calls and Standard I/O

System Calls and Standard I/O System Calls and Standard I/O Professor Jennifer Rexford http://www.cs.princeton.edu/~jrex 1 Goals of Today s Class System calls o How a user process contacts the Operating System o For advanced services

More information

Operating Systems. 05. Threads. Paul Krzyzanowski. Rutgers University. Spring 2015

Operating Systems. 05. Threads. Paul Krzyzanowski. Rutgers University. Spring 2015 Operating Systems 05. Threads Paul Krzyzanowski Rutgers University Spring 2015 February 9, 2015 2014-2015 Paul Krzyzanowski 1 Thread of execution Single sequence of instructions Pointed to by the program

More information

Memory management in C: The heap and the stack

Memory management in C: The heap and the stack Memory management in C: The heap and the stack Leo Ferres Department of Computer Science Universidad de Concepción leo@inf.udec.cl October 7, 2010 1 Introduction When a program is loaded into memory, it

More information

CS420: Operating Systems OS Services & System Calls

CS420: Operating Systems OS Services & System Calls NK YORK COLLEGE OF PENNSYLVANIA HG OK 2 YORK COLLEGE OF PENNSYLVAN OS Services & System Calls James Moscola Department of Physical Sciences York College of Pennsylvania Based on Operating System Concepts,

More information

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Lecture 03 Bits, Bytes and Data Types In this lecture Computer Languages Assembly Language The compiler Operating system Data and program instructions Bits, Bytes and Data Types ASCII table Data Types

More information

CSC 2405: Computer Systems II

CSC 2405: Computer Systems II CSC 2405: Computer Systems II Spring 2013 (TR 8:30-9:45 in G86) Mirela Damian http://www.csc.villanova.edu/~mdamian/csc2405/ Introductions Mirela Damian Room 167A in the Mendel Science Building mirela.damian@villanova.edu

More information

Lecture 25 Systems Programming Process Control

Lecture 25 Systems Programming Process Control Lecture 25 Systems Programming Process Control A process is defined as an instance of a program that is currently running. A uni processor system or single core system can still execute multiple processes

More information

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study CS 377: Operating Systems Lecture 25 - Linux Case Study Guest Lecturer: Tim Wood Outline Linux History Design Principles System Overview Process Scheduling Memory Management File Systems A review of what

More information

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture Last Class: OS and Computer Architecture System bus Network card CPU, memory, I/O devices, network card, system bus Lecture 3, page 1 Last Class: OS and Computer Architecture OS Service Protection Interrupts

More information

Process definition Concurrency Process status Process attributes PROCESES 1.3

Process definition Concurrency Process status Process attributes PROCESES 1.3 Process Management Outline Main concepts Basic services for process management (Linux based) Inter process communications: Linux Signals and synchronization Internal process management Basic data structures:

More information

5. Processes and Memory Management

5. Processes and Memory Management 5. Processes and Memory Management 5. Processes and Memory Management Process Abstraction Introduction to Memory Management Process Implementation States and Scheduling Programmer Interface Process Genealogy

More information

Operating Systems 4 th Class

Operating Systems 4 th Class Operating Systems 4 th Class Lecture 1 Operating Systems Operating systems are essential part of any computer system. Therefore, a course in operating systems is an essential part of any computer science

More information

CS3600 SYSTEMS AND NETWORKS

CS3600 SYSTEMS AND NETWORKS CS3600 SYSTEMS AND NETWORKS NORTHEASTERN UNIVERSITY Lecture 2: Operating System Structures Prof. Alan Mislove (amislove@ccs.neu.edu) Operating System Services Operating systems provide an environment for

More information

Linux/UNIX System Programming. POSIX Shared Memory. Michael Kerrisk, man7.org c 2015. February 2015

Linux/UNIX System Programming. POSIX Shared Memory. Michael Kerrisk, man7.org c 2015. February 2015 Linux/UNIX System Programming POSIX Shared Memory Michael Kerrisk, man7.org c 2015 February 2015 Outline 22 POSIX Shared Memory 22-1 22.1 Overview 22-3 22.2 Creating and opening shared memory objects 22-10

More information

Operating Systems and Networks

Operating Systems and Networks recap Operating Systems and Networks How OS manages multiple tasks Virtual memory Brief Linux demo Lecture 04: Introduction to OS-part 3 Behzad Bordbar 47 48 Contents Dual mode API to wrap system calls

More information

Minix Mini Unix (Minix) basically, a UNIX - compatible operating system. Minix is small in size, with microkernel-based design. Minix has been kept

Minix Mini Unix (Minix) basically, a UNIX - compatible operating system. Minix is small in size, with microkernel-based design. Minix has been kept Minix Mini Unix (Minix) basically, a UNIX - compatible operating system. Minix is small in size, with microkernel-based design. Minix has been kept (relatively) small and simple. Minix is small, it is

More information

Debugging with TotalView

Debugging with TotalView Tim Cramer 17.03.2015 IT Center der RWTH Aachen University Why to use a Debugger? If your program goes haywire, you may... ( wand (... buy a magic... read the source code again and again and...... enrich

More information

CSC230 Getting Starting in C. Tyler Bletsch

CSC230 Getting Starting in C. Tyler Bletsch CSC230 Getting Starting in C Tyler Bletsch What is C? The language of UNIX Procedural language (no classes) Low-level access to memory Easy to map to machine language Not much run-time stuff needed Surprisingly

More information

Assignment0: Linux Basics and /proc

Assignment0: Linux Basics and /proc Assignment0: Linux Basics and /proc CS314 Operating Systems This project was adapted from Gary Nutt s Excellent Book Kernel Projects for Linux published by Addison-Wesley 2001. You will learn several important

More information

Operating System Overview. Otto J. Anshus

Operating System Overview. Otto J. Anshus Operating System Overview Otto J. Anshus A Typical Computer CPU... CPU Memory Chipset I/O bus ROM Keyboard Network A Typical Computer System CPU. CPU Memory Application(s) Operating System ROM OS Apps

More information

Operating System Structure

Operating System Structure Operating System Structure Lecture 3 Disclaimer: some slides are adopted from the book authors slides with permission Recap Computer architecture CPU, memory, disk, I/O devices Memory hierarchy Architectural

More information

Operating Systems. Design and Implementation. Andrew S. Tanenbaum Melanie Rieback Arno Bakker. Vrije Universiteit Amsterdam

Operating Systems. Design and Implementation. Andrew S. Tanenbaum Melanie Rieback Arno Bakker. Vrije Universiteit Amsterdam Operating Systems Design and Implementation Andrew S. Tanenbaum Melanie Rieback Arno Bakker Vrije Universiteit Amsterdam Operating Systems - Winter 2012 Outline Introduction What is an OS? Concepts Processes

More information

Outline. Operating Systems Design and Implementation. Chap 1 - Overview. What is an OS? 28/10/2014. Introduction

Outline. Operating Systems Design and Implementation. Chap 1 - Overview. What is an OS? 28/10/2014. Introduction Operating Systems Design and Implementation Andrew S. Tanenbaum Melanie Rieback Arno Bakker Outline Introduction What is an OS? Concepts Processes and Threads Memory Management File Systems Vrije Universiteit

More information

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont. Objectives To describe the services an operating system provides to users, processes, and other systems To discuss the various ways of structuring an operating system Chapter 2: Operating-System Structures

More information

Leak Check Version 2.1 for Linux TM

Leak Check Version 2.1 for Linux TM Leak Check Version 2.1 for Linux TM User s Guide Including Leak Analyzer For x86 Servers Document Number DLC20-L-021-1 Copyright 2003-2009 Dynamic Memory Solutions LLC www.dynamic-memory.com Notices Information

More information

Chapter 3: Operating-System Structures. System Components Operating System Services System Calls System Programs System Structure Virtual Machines

Chapter 3: Operating-System Structures. System Components Operating System Services System Calls System Programs System Structure Virtual Machines Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines Operating System Concepts 3.1 Common System Components

More information

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C 1 An essential part of any embedded system design Programming 2 Programming in Assembly or HLL Processor and memory-sensitive

More information

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson CS 3530 Operating Systems L02 OS Intro Part 1 Dr. Ken Hoganson Chapter 1 Basic Concepts of Operating Systems Computer Systems A computer system consists of two basic types of components: Hardware components,

More information

III. Process Scheduling

III. Process Scheduling Intended Schedule III. Process Scheduling Date Lecture Hand out Submission 0 20.04. Introduction to Operating Systems Course registration 1 27.04. Systems Programming using C (File Subsystem) 1. Assignment

More information

III. Process Scheduling

III. Process Scheduling III. Process Scheduling 1 Intended Schedule Date Lecture Hand out Submission 0 20.04. Introduction to Operating Systems Course registration 1 27.04. Systems Programming using C (File Subsystem) 1. Assignment

More information

7.2 Examining Processes on the Command Line

7.2 Examining Processes on the Command Line Chapter 7 Process Architecture and Control Concepts Covered Memory architecture of a process Memory structures Viewing memory layout Process structure Executable le format Process creation Process synchronization

More information

SQLITE C/C++ TUTORIAL

SQLITE C/C++ TUTORIAL http://www.tutorialspoint.com/sqlite/sqlite_c_cpp.htm SQLITE C/C++ TUTORIAL Copyright tutorialspoint.com Installation Before we start using SQLite in our C/C++ programs, we need to make sure that we have

More information

Shared Address Space Computing: Programming

Shared Address Space Computing: Programming Shared Address Space Computing: Programming Alistair Rendell See Chapter 6 or Lin and Synder, Chapter 7 of Grama, Gupta, Karypis and Kumar, and Chapter 8 of Wilkinson and Allen Fork/Join Programming Model

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

Laboratorio di Sistemi Operativi Anno Accademico 2009-2010

Laboratorio di Sistemi Operativi Anno Accademico 2009-2010 Laboratorio di Sistemi Operativi Anno Accademico 2009-2010 Software Development with umps Part 2 Mauro Morsiani Copyright Permission is granted to copy, distribute and/or modify this document under the

More information

umps software development

umps software development Laboratorio di Sistemi Operativi Anno Accademico 2006-2007 Software Development with umps Part 2 Mauro Morsiani Software development with umps architecture: Assembly language development is cumbersome:

More information

Linux Kernel Architecture

Linux Kernel Architecture Linux Kernel Architecture Amir Hossein Payberah payberah@yahoo.com Contents What is Kernel? Kernel Architecture Overview User Space Kernel Space Kernel Functional Overview File System Process Management

More information

Embedded Software development Process and Tools: Lesson-4 Linking and Locating Software

Embedded Software development Process and Tools: Lesson-4 Linking and Locating Software Embedded Software development Process and Tools: Lesson-4 Linking and Locating Software 1 1. Linker 2 Linker Links the compiled codes of application software, object codes from library and OS kernel functions.

More information

Implementing Rexx Handlers in NetRexx/Java/Rexx

Implementing Rexx Handlers in NetRexx/Java/Rexx Institut für Betriebswirtschaftslehre und Wirtschaftsinformatik Implementing Rexx Handlers in NetRexx/Java/Rexx The 2012 International Rexx Symposium Rony G. Flatscher Wirtschaftsuniversität Wien Augasse

More information

Introduction. What is an Operating System?

Introduction. What is an Operating System? Introduction What is an Operating System? 1 What is an Operating System? 2 Why is an Operating System Needed? 3 How Did They Develop? Historical Approach Affect of Architecture 4 Efficient Utilization

More information

CSE 120 Principles of Operating Systems. Modules, Interfaces, Structure

CSE 120 Principles of Operating Systems. Modules, Interfaces, Structure CSE 120 Principles of Operating Systems Fall 2000 Lecture 3: Operating System Modules, Interfaces, and Structure Geoffrey M. Voelker Modules, Interfaces, Structure We roughly defined an OS as the layer

More information

Operating System Structures

Operating System Structures COP 4610: Introduction to Operating Systems (Spring 2015) Operating System Structures Zhi Wang Florida State University Content Operating system services User interface System calls System programs Operating

More information

Example of Standard API

Example of Standard API 16 Example of Standard API System Call Implementation Typically, a number associated with each system call System call interface maintains a table indexed according to these numbers The system call interface

More information

C Primer. Fall Introduction C vs. Java... 1

C Primer. Fall Introduction C vs. Java... 1 CS 33 Intro Computer Systems Doeppner C Primer Fall 2016 Contents 1 Introduction 1 1.1 C vs. Java.......................................... 1 2 Functions 1 2.1 The main() Function....................................

More information

Virtual Servers. Virtual machines. Virtualization. Design of IBM s VM. Virtual machine systems can give everyone the OS (and hardware) that they want.

Virtual Servers. Virtual machines. Virtualization. Design of IBM s VM. Virtual machine systems can give everyone the OS (and hardware) that they want. Virtual machines Virtual machine systems can give everyone the OS (and hardware) that they want. IBM s VM provided an exact copy of the hardware to the user. Virtual Servers Virtual machines are very widespread.

More information

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine 7 Objectives After completing this lab you will: know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine Introduction Branches and jumps provide ways to change

More information

REAL TIME OPERATING SYSTEM PROGRAMMING-II: II: Windows CE, OSEK and Real time Linux. Lesson-12: Real Time Linux

REAL TIME OPERATING SYSTEM PROGRAMMING-II: II: Windows CE, OSEK and Real time Linux. Lesson-12: Real Time Linux REAL TIME OPERATING SYSTEM PROGRAMMING-II: II: Windows CE, OSEK and Real time Linux Lesson-12: Real Time Linux 1 1. Real Time Linux 2 Linux 2.6.x Linux is after Linus Torvalds, father of the Linux operating

More information

Simple C Programs. Goals for this Lecture. Help you learn about:

Simple C Programs. Goals for this Lecture. Help you learn about: Simple C Programs 1 Goals for this Lecture Help you learn about: Simple C programs Program structure Defining symbolic constants Detecting and reporting failure Functionality of the gcc command Preprocessor,

More information

Main Memory. Memory. Address binding. Memory spaces. All processes need main memory.

Main Memory. Memory. Address binding. Memory spaces. All processes need main memory. Memory If we define memory as a place where data is stored there are many levels of memory: Processor registers Primary (or main) memory RAM Secondary memory slower and more permanent disks Tertiary memory

More information

C++ Programming Language

C++ Programming Language C++ Programming Language Lecturer: Yuri Nefedov 7th and 8th semesters Lectures: 34 hours (7th semester); 32 hours (8th semester). Seminars: 34 hours (7th semester); 32 hours (8th semester). Course abstract

More information

CHAPTER 15: Operating Systems: An Overview

CHAPTER 15: Operating Systems: An Overview CHAPTER 15: Operating Systems: An Overview The Architecture of Computer Hardware, Systems Software & Networking: An Information Technology Approach 4th Edition, Irv Englander John Wiley and Sons 2010 PowerPoint

More information

W4118 Operating Systems. Junfeng Yang

W4118 Operating Systems. Junfeng Yang W4118 Operating Systems Junfeng Yang Outline Linux overview Interrupt in Linux System call in Linux What is Linux A modern, open-source OS, based on UNIX standards 1991, 0.1 MLOC, single developer Linus

More information

Operating Systems. Privileged Instructions

Operating Systems. Privileged Instructions Operating Systems Operating systems manage processes and resources Processes are executing instances of programs may be the same or different programs process 1 code data process 2 code data process 3

More information

Operating Systems for Parallel Processing Assistent Lecturer Alecu Felician Economic Informatics Department Academy of Economic Studies Bucharest

Operating Systems for Parallel Processing Assistent Lecturer Alecu Felician Economic Informatics Department Academy of Economic Studies Bucharest Operating Systems for Parallel Processing Assistent Lecturer Alecu Felician Economic Informatics Department Academy of Economic Studies Bucharest 1. Introduction Few years ago, parallel computers could

More information

CS5460: Operating Systems

CS5460: Operating Systems CS5460: Operating Systems Lecture 13: Memory Management (Chapter 8) Where are we? Basic OS structure, HW/SW interface, interrupts, scheduling Concurrency Memory management Storage management Other topics

More information

Lab 2: Implementing a Shell COMPSCI 310: Introduction to Operating Systems

Lab 2: Implementing a Shell COMPSCI 310: Introduction to Operating Systems Lab 2: Implementing a Shell COMPSCI 310: Introduction to Operating Systems 1 Shells are cool Unix [2] embraces the philosophy: Write programs that do one thing and do it well. Write programs to work together.

More information

Object Oriented Software Design II

Object Oriented Software Design II Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February

More information

Multi-core Programming System Overview

Multi-core Programming System Overview Multi-core Programming System Overview Based on slides from Intel Software College and Multi-Core Programming increasing performance through software multi-threading by Shameem Akhter and Jason Roberts,

More information

CIS 551 / TCOM 401 Computer and Network Security. Spring 2005 Lecture 4

CIS 551 / TCOM 401 Computer and Network Security. Spring 2005 Lecture 4 CIS 551 / TCOM 401 Computer and Network Security Spring 2005 Lecture 4 Access Control: The Big Picture Objects - resources being protected E.g. files, devices, etc. Subjects - active entities E.g. processes,

More information

Intel P6 Systemprogrammering 2007 Föreläsning 5 P6/Linux Memory System

Intel P6 Systemprogrammering 2007 Föreläsning 5 P6/Linux Memory System Intel P6 Systemprogrammering 07 Föreläsning 5 P6/Linux ory System Topics P6 address translation Linux memory management Linux page fault handling memory mapping Internal Designation for Successor to Pentium

More information

Chapter 3 Operating-System Structures

Chapter 3 Operating-System Structures Contents 1. Introduction 2. Computer-System Structures 3. Operating-System Structures 4. Processes 5. Threads 6. CPU Scheduling 7. Process Synchronization 8. Deadlocks 9. Memory Management 10. Virtual

More information

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Processes and Non-Preemptive Scheduling. Otto J. Anshus Processes and Non-Preemptive Scheduling Otto J. Anshus 1 Concurrency and Process Challenge: Physical reality is Concurrent Smart to do concurrent software instead of sequential? At least we want to have

More information

MPATE-GE 2618: C Programming for Music Technology. Unit 1.1

MPATE-GE 2618: C Programming for Music Technology. Unit 1.1 MPATE-GE 2618: C Programming for Music Technology Unit 1.1 What is an algorithm? An algorithm is a precise, unambiguous procedure for producing certain results (outputs) from given data (inputs). It is

More information

Writing a C-based Client/Server

Writing a C-based Client/Server Working the Socket Writing a C-based Client/Server Consider for a moment having the massive power of different computers all simultaneously trying to compute a problem for you -- and still being legal!

More information

An Implementation Of Multiprocessor Linux

An Implementation Of Multiprocessor Linux An Implementation Of Multiprocessor Linux This document describes the implementation of a simple SMP Linux kernel extension and how to use this to develop SMP Linux kernels for architectures other than

More information

Parallelization: Binary Tree Traversal

Parallelization: Binary Tree Traversal By Aaron Weeden and Patrick Royal Shodor Education Foundation, Inc. August 2012 Introduction: According to Moore s law, the number of transistors on a computer chip doubles roughly every two years. First

More information

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,

More information

IT304 Experiment 2 To understand the concept of IPC, Pipes, Signals, Multi-Threading and Multiprocessing in the context of networking.

IT304 Experiment 2 To understand the concept of IPC, Pipes, Signals, Multi-Threading and Multiprocessing in the context of networking. Aim: IT304 Experiment 2 To understand the concept of IPC, Pipes, Signals, Multi-Threading and Multiprocessing in the context of networking. Other Objective of this lab session is to learn how to do socket

More information

Grundlagen der Betriebssystemprogrammierung

Grundlagen der Betriebssystemprogrammierung Grundlagen der Betriebssystemprogrammierung Präsentation A3, A4, A5, A6 21. März 2013 IAIK Grundlagen der Betriebssystemprogrammierung 1 / 73 1 A3 - Function Pointers 2 A4 - C++: The good, the bad and

More information

Operating System Components

Operating System Components Lecture Overview Operating system software introduction OS components OS services OS structure Operating Systems - April 24, 2001 Operating System Components Process management Memory management Secondary

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

Lecture 25 Symbian OS

Lecture 25 Symbian OS CS 423 Operating Systems Design Lecture 25 Symbian OS Klara Nahrstedt Fall 2011 Based on slides from Andrew S. Tanenbaum textbook and other web-material (see acknowledgements) cs423 Fall 2011 1 Overview

More information

/* File: blkcopy.c. size_t n

/* File: blkcopy.c. size_t n 13.1. BLOCK INPUT/OUTPUT 505 /* File: blkcopy.c The program uses block I/O to copy a file. */ #include main() { signed char buf[100] const void *ptr = (void *) buf FILE *input, *output size_t

More information

Chapter 10 Case Study 1: LINUX

Chapter 10 Case Study 1: LINUX MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 10 Case Study 1: LINUX History of UNIX and Linux UNICS PDP-11 UNIX Portable UNIX Berkeley UNIX Standard UNIX MINIX Linux UNIX/Linux Goals

More information

Chapter 2 System Structures

Chapter 2 System Structures Chapter 2 System Structures Operating-System Structures Goals: Provide a way to understand an operating systems Services Interface System Components The type of system desired is the basis for choices

More information

MPLAB TM C30 Managed PSV Pointers. Beta support included with MPLAB C30 V3.00

MPLAB TM C30 Managed PSV Pointers. Beta support included with MPLAB C30 V3.00 MPLAB TM C30 Managed PSV Pointers Beta support included with MPLAB C30 V3.00 Contents 1 Overview 2 1.1 Why Beta?.............................. 2 1.2 Other Sources of Reference..................... 2 2

More information

Chapter 3: Operating-System Structures. Common System Components

Chapter 3: Operating-System Structures. Common System Components Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation System Generation 3.1

More information

OPERATING SYSTEM SERVICES

OPERATING SYSTEM SERVICES OPERATING SYSTEM SERVICES USER INTERFACE Command line interface(cli):uses text commands and a method for entering them Batch interface(bi):commands and directives to control those commands are entered

More information

Audit Trail Administration

Audit Trail Administration Audit Trail Administration 0890431-030 August 2003 Copyright 2003 by Concurrent Computer Corporation. All rights reserved. This publication or any part thereof is intended for use with Concurrent Computer

More information

Virtual Memory and Address Translation

Virtual Memory and Address Translation Virtual Memory and Address Translation Review: the Program and the Process VAS Process text segment is initialized directly from program text section. sections Process data segment(s) are initialized from

More information

ARUNNING INSTANCE OF A PROGRAM IS CALLED A PROCESS. If you have two

ARUNNING INSTANCE OF A PROGRAM IS CALLED A PROCESS. If you have two 3 Processes ARUNNING INSTANCE OF A PROGRAM IS CALLED A PROCESS. If you have two terminal windows showing on your screen, then you are probably running the same terminal program twice you have two terminal

More information

Migration of Process Credentials

Migration of Process Credentials C H A P T E R - 5 Migration of Process Credentials 5.1 Introduction 5.2 The Process Identifier 5.3 The Mechanism 5.4 Concluding Remarks 100 CHAPTER 5 Migration of Process Credentials 5.1 Introduction Every

More information

Configuring Rexx Interpreter Instances from NetRexx/Java

Configuring Rexx Interpreter Instances from NetRexx/Java Institut für Betriebswirtschaftslehre und Wirtschaftsinformatik Configuring Rexx Interpreter Instances from NetRexx/Java The 2012 International Rexx Symposium Rony G. Flatscher Wirtschaftsuniversität Wien

More information

Module 20: The Linux System

Module 20: The Linux System Module 20: The Linux System History Design Principles Kernel Modules Process Management Scheduling Memory Management File Systems Input and Output Interprocess Communication Network Structure Security

More information

Real Time Programming: Concepts

Real Time Programming: Concepts Real Time Programming: Concepts Radek Pelánek Plan at first we will study basic concepts related to real time programming then we will have a look at specific programming languages and study how they realize

More information

The Linux Kernel: Process Management. CS591 (Spring 2001)

The Linux Kernel: Process Management. CS591 (Spring 2001) The Linux Kernel: Process Management Process Descriptors The kernel maintains info about each process in a process descriptor, of type task_struct. See include/linux/sched.h Each process descriptor contains

More information

CSE331: Introduction to Networks and Security. Lecture 34 Fall 2006

CSE331: Introduction to Networks and Security. Lecture 34 Fall 2006 CSE331: Introduction to Networks and Security Lecture 34 Fall 2006 Announcements Problem with Crypto.java Look for a new Crypto.java file later today Project 4 is due Dec. 8th at midnight. Homework 3 is

More information

Chapter 12 File Management

Chapter 12 File Management Operating Systems: Internals and Design Principles, 6/E William Stallings Chapter 12 File Management Dave Bremer Otago Polytechnic, N.Z. 2008, Prentice Hall Roadmap Overview File organisation and Access

More information

Q N X S O F T W A R E D E V E L O P M E N T P L A T F O R M v 6. 4. 10 Steps to Developing a QNX Program Quickstart Guide

Q N X S O F T W A R E D E V E L O P M E N T P L A T F O R M v 6. 4. 10 Steps to Developing a QNX Program Quickstart Guide Q N X S O F T W A R E D E V E L O P M E N T P L A T F O R M v 6. 4 10 Steps to Developing a QNX Program Quickstart Guide 2008, QNX Software Systems GmbH & Co. KG. A Harman International Company. All rights

More information

Chapter 12 File Management. Roadmap

Chapter 12 File Management. Roadmap Operating Systems: Internals and Design Principles, 6/E William Stallings Chapter 12 File Management Dave Bremer Otago Polytechnic, N.Z. 2008, Prentice Hall Overview Roadmap File organisation and Access

More information

Computer System Structure

Computer System Structure Computer System Structure Reading: Silberschatz chapter 3 Additional Reading: Stallings chapter 2 EEL 602 1 Outline OS Services User Interfaces System Call OS Design OS Implementation System Structure

More information

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 1 Goals of the Lecture Present an introduction to Objective-C 2.0 Coverage of the language will be INCOMPLETE

More information