Page 407 - DCAP103_Principle of operating system
P. 407

Principles of Operating Systems



                   Notes         14.1 Overview of Linux

                                 In  this  section,  we  will  provide  a  general  introduction  to  Linux  and  how  it  is  used,  for  the
                                 benefit of readers not already familiar with it. Nearly all of this material applies to just about all
                                 UNIX variants with only small deviations. Although Linux has several graphical interfaces, the
                                 focus here is how Linux appears to a programmer working in a shell window on X. Subsequent
                                 sections will focus on system calls and how it works inside.

                                 14.1.1 Linux Goals
                                 UNIX was always an interactive system designed to handle multiple processes and multiple users
                                 at the same time. It was designed by programmers, for programmers, to use in an environment
                                 in which the majority of the users are relatively sophisticated and are engaged in (often quite
                                 complex) software development projects. In many cases, a large number of programmers are
                                 actively cooperating to produce a single system, so UNIX has extensive facilities to allow people
                                 to work together and share information in controlled ways. The model of a group of experienced
                                 programmers working together closely to produce advanced software is obviously very different
                                 from the personal computer model of a single beginner working alone with a word processor,
                                 and  this  difference  is  reflected  throughout  UNIX  from  start  to  finish.  It  is  only  natural  that
                                 Linux inherited many of these goals, even though the first version was for a personal computer.
                                 What is it that good programmers want in a system? To start with, most like their systems to be
                                 simple, elegant, and consistent. For example, at the lowest level, a file should just be a collection
                                 of bytes. Having different classes of files for sequential access, random access, keyed access,
                                 remote access, etc. (as mainframes do) just gets in the way.
                                 Similarly, if the command
                                 ls A*
                                 means list all the files beginning with ‘’A’’ then the command
                                 rm A*
                                 should mean remove all the files beginning with “A” and not remove the one file whose name
                                 consists of an ‘’A’’ and an asterisk. This characteristic is sometimes called the principle of least
                                 surprise.
                                 Another  thing  that  experienced  programmers  generally  want  is  power  and  flexibility.  This
                                 means that a system should have a small number of basic elements that can be combined in an
                                 infinite variety of ways to suit the application. One of the basic guidelines behind Linux is that
                                 every program should do just one thing and do it well. Thus compilers do not produce listings,
                                 because other programs can do much better.
                                 Finally,  most  programmers  have  a  strong  dislike  for  useless  redundancy.  Why  type  copy
                                 when cp is enough? To extract all the lines containing the string “ard” from the file f, the Linux
                                 programmer types grep ard f. The opposite approach is to have the programmer first select the
                                 grep program (with no arguments), and then have grep announce itself by saying: “Hi, I’m grep,
                                 I look for patterns in files. Please enter your pattern.” After getting the pattern, grep prompts for
                                 a file name. Then it asks if there are any more file names. Finally, it summarizes what it is going
                                 to do and ask if that is correct. While this kind of user interface may or may not be suitable for
                                 rank novices, it irritates skilled programmers to no end.
                                 14.1.2 Interfaces to Linux

                                 A  Linux  system  can  be  regarded  as  a  kind  of  pyramid,  as  illustrated  in  Figure  14.1.  At  the
                                 bottom is the hardware, consisting of the CPU, memory, disks, a monitor and keyboard, and
                                 other devices running on the bare hardware is the operating system. Its function is to control
                                 the hardware and provide a system call interface to all the programs. These system calls allow
                                 user programs to create and manage processes, files, and other resources.


        400                               LOVELY PROFESSIONAL UNIVERSITY
   402   403   404   405   406   407   408   409   410   411   412