The operating system is the code that carries out the system calls. Editors, compilers, assemblers, linkers, and command interpreters certainly are not part of the operating system, even though they are important and useful. At the risk of confusing things to some extent, in this section we will look in brief at the UNIX command interpreter, called the shell. Though it is not part of the operating system, it makes heavy use of many operating system features and therefore serves as a good example of how the system calls can be used. It is also the primary interface between a user sitting at his terminal and the operating system, unless the user is using a graphical user interface. Many shells exist, including sh, csh, ksh, and bash. All of them support the functionality explained below, which derives from the original shell (sh).
When any user logs in, a shell is started up. The shell has the terminal as standard input and standard output. It starts out by typing the prompt, a character such as a dollar sign, which tells the user that the shell is waiting to accept a command. If the user now types
for instance, the shell creates a child process and runs the date program as the child. While the child process is running, the shell waits for it to terminate. When the child finishes, the shell types the prompt again and tries to read the next input line.
The user can define that standard output be redirected to a file, for instance,
Similarly, standard input can be redirected, as in
which invokes the sort program with input taken from file1 and output sent to file2.
The output of one program can be used as the input for another program by connecting them with a pipe. Thus
cat file1 file2 file3 | sort >/dev/lp
invokes the cat program to concatenate three files and send the output to sort to arrange all the lines in alphabetical order. The output of sort is redirected to the file /dev/lp, normally the printer.
if a user puts an ampersand after a command, the shell does not wait for it to complete. Instead it just gives a prompt immediately. Consequently,
cat file1 file2 file3 | sort >/dev/lp &
starts up the sort as a background job, permitting the user to continue working normally while the sort is going on. The shell has a number of other interesting features, which we do not have space to discuss here. Most books on UNIX discuss the shell at some length (e.g., Kernighan and Pike, 1984; Kochan and Wood, 1990; Medinets, 1999; Newham and Rosenblatt, 1998; and Robbins, 1999).
Many personal computers use a GUI these days. Actually, the GUI is just a program running on top of the operating system, like a shell. In Linux systems, this fact is made obvious because the user has a choice of (at least) two GUIs: Gnome and KDE or none at all (using a terminal window on Xll). In Windows, it is also possible to replace the standard GUI desktop (Windows Explorer) with a different program by changing some values in the registry, although few people do this.
Tagssystem calls, shell, personal computer
- MEMORY MANAGEMENT
- Message Passing
- Sleep and Wakeup
- Implementing Threads in the Kernel
- Process Termination
- Process Creation
- OPERATING SYSTEM STRUCTURE
- The Windows Win32 API
- Miscellaneous System Calls
- System Calls for Directory Management
- System Calls for File Management
- System Calls for Process Management
- SYSTEM CALLS
- Handheld Computer Operating Systems
- Multiprocessor Operating Systems