Linux Utility Programs( 2) Program Typical use cat Concatenate multiple files to standard output chmod Change file protection mode Copy one or more files cut Cut columns of text from a file Search a file for some pattern head Extract the first lines of a file ls List director make Compile files to build a binary mkdir Make a directory Octal dump a file paste Paste columns of text into a file pr Format a file for printing List running processes Remove one or more files rmdir Remove a directory sort Sort a file of lines alphabetically Extract the last lines of a file Translate between character sets Figure 10-2. A few of the common Linux utility programs required by POsIX Tanenbaum, Modern Operating Systems 3 e, (c)2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 10-2. A few of the common Linux utility programs required by POSIX. Linux Utility Programs (2) Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Kernel structure System calls Memory mgt Process mgt 1O component component component Virtual file system Virtual Signal memory handling File Terminals Sockets systems Paging Process/thread 乱 Network Generic page creation protocols block layer I replacement」 termination 1/0 scheduler CharacterNetwork Block P CPU device device device drivers cache scheduling drivers drivers Interrupts Dispatcher Figure 10-3. Structure of the Linux kernel Tanenbaum, Modern Operating Systems 3 e, (c)2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 10-3. Structure of the Linux kernel Kernel Structure Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Processes in linux Linux, a multiprogramming system Many independent processes running fork system call creates process k() /* if the fork succeeds, pid >0 in the parent * if(pid O)( handle_error() / fork failed (e.g, memory or some table is full)*/ 3 else if(pid>0)( / parent code goes here. /* else /* child code goes here. /* Figure 10-4. Process creation in linux Tanenbaum, Modern Operating Systems 3 e, (c)2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Figure 10-4. Process creation in Linux. Processes in Linux Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 Linux, a multiprogramming system • Many independent processes running • fork system call creates process
Processes in linux Processes can communicate using message passing, like pipes sort <f head Tanenbaum, Modern Operating Systems 3 e, (c)2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Processes in Linux Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 Processes can communicate using message passing, like pipes • sort <f | head
Processes in linux Processes can communicate using software interrupts, like signal Signal Cause SiGaBRT Sent to abort a process and force a core dump SIGALRM The alarm clock has gone off SIGFPE A floating-point error has occurred (e.g, division by O SIGHUP The phone line the process was using has been hung up SIGILL The user has hit the del key to interrupt the process SiGQUIT The user has hit the key requesting a core dump SIGKILL Sent to kill a process(cannot be caught or ignored) SIGPIPE The process has written to a pipe which has no readers SIGSEGv The process has referenced an invalid memory address SIGTERM Used to request that a process terminate gracefully SIGUSR1 Available for application-defined purposes SIGUSR2 Available for application-defined purposes Tanenbaum, Modern Operating Systems 3 e, (c)2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639
Processes in Linux Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved. 0-13-6006639 Processes can communicate using software interrupts, like signal