Thursday, 19 September 2013
Command Interpreter
Some operating systems include the command interpreter in the kernel. Others,
such as Windows XP and UNIX, treat the command interpreter as a special
program that is running when a job is initiated or when a user first logs
on (on interactive systems). On systems with multiple command interpreters
to choose from, the interpreters are known as shells. For example, on UNIX
and Linux systems, there are several different shells a user may choose from
including the Bourne shell, C shell, Bourne-Again shell, the Korn shell, etc. Most
shells provide similar functionality with only minor differences; most users
choose a shell based upon personal preference.The main function of the command interpreter is to get and execute the next
user-specified command. Many of the commands given at this level manipulate
files: create, delete, list, print, copy, execute, and so on. The MS-DOS and UNIX
shells operate in this way. There are two general ways in which these commands
can be implemented.
In one approach, the command interpreter itself contains the code to
execute the command. For example, a command to delete a file may cause
the command interpreter to jump to a section of its code that sets up the
parameters and makes the appropriate system call. In this case, the number of
commands that can be given determines the size of the command interpreter,
since each command requires its own implementing code.
An alternative approach—used by UNIX, among other operating systems
—implements most commands through system programs. In this case, the
command interpreter does not understand the command in any way; it merely
uses the command to identify a file to be loaded into memory and executed.
Thus, the UNIX command to delete a file
rm f i l e . t x t
would search for a file called rm, load the file into memory, and execute it with
the parameter f i l e . txt. The function associated with the rm command would
be defined completely by the code in the file rm. In this way, programmers can
add new commands to the system easily by creating new files with the proper
names. The command-interpreter program, which can be small, does not have
to be changed for new commands to be added.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment