Page 414 - DCAP103_Principle of operating system
P. 414

Unit 14: Case Study of Linux Operating System



            While  the  three  components  are  represented  separately  in  the  figure,  they  are  highly   Notes
            interdependent. File systems typically access files through the block devices. However, in order
            to hide the large latencies of disk accesses, files are copied into the page cache in main memory.
            Some files may even be dynamically created and may only have an in-memory representation,
            such as files providing some runtime resource usage information. In addition, the virtual memory
            systems may rely on a disk partition or in-file swap area to back up parts of the main memory
            when it needs to free up certain pages, and therefore relies on the I/O component. Numerous
            other interdependencies exist. In addition to the static in-kernel components, Linux supports
            dynamically loadable modules. These modules can be used to add or replace the default device
            drivers, file system, networking, or other kernel codes. The modules are not shown in Figure 14.3.
            Finally, at the very top is the system call interface into the kernel. All system calls come here,
            cause a trap which switches the execution from user mode into protected kernel mode and
            passes control to one of the kernel components described above.

            14.2 Processes in Linux

            In the previous sections, we started out by looking at Linux as viewed from the keyboard, that
            is, what the user sees in an xterm window. We gave examples of shell commands and utility
            programs that are frequently used. We ended with a brief overview of the system structure.
            Now it is time to dig deeply into the kernel and look more closely at the basic concepts that
            Linux supports, namely, processes, memory, the file system, and input/output. These notions
            are important because the system calls—the interface to the operating system itself—manipulate
            them. For example, system calls exist to create processes and threads, allocate memory, open
            files, and do I/O.
            Unfortunately, with so many versions of Linux in existence, there are some differences between
            them. In this unit, we will emphasize the features common to all of them rather than focus
            on any one specific version. Thus in certain sections (especially implementation sections), the
            discussion may not apply equally to every version.
            14.2.1 Fundamental Concepts of Process in Linux

            The main active entities in a Linux system are the processes. Linux processes are very similar
            to  the  classical  sequential  processes.  Each  process  runs  a  single  program  and  initially  has  a
            single thread of control. In other words, it has one program counter, which keeps track of the
            next instruction to be executed. Linux allows a process to create additional threads once it starts
            executing.
            Linux is a multiprogramming system, so multiple, independent processes may be running at
            the same time. Each user may have several active processes at once; so on a large system, there
            may be hundreds or even thousands of processes running. In fact, on most of the single-user
            workstations, even when the user is absent, dozens of background processes, called daemons,
            are running. These are started by a shell script when the system is booted. (‘’Daemon’’ is a
            variant  spelling  of  ‘’demon,’’  which  is  a  self-employed  evil  spirit.)  A  typical  daemon  is  the
            cron daemon. It wakes up once a minute to check if there is any work for it to do. If so, it does
            the work. Then it goes back to sleep until it is time for the next check. This daemon is needed
            because it is possible in Linux to schedule activities minutes, hours, days, or even months in
            the future. For example, suppose a user has a dentist appointment at 3 o’clock next Tuesday.
            He can make an entry in the cron daemon’s database telling the daemon to beep at him at, say,
            2:30. When the appointed day and time arrives, the cron daemon sees that it has work to do,
            and starts up the beeping program as a new process. The cron daemon is also used to start up
            periodic activities, such as making daily disk backups at 4 a.m., or reminding forgetful users




                                             LOVELY PROFESSIONAL UNIVERSITY                                   407
   409   410   411   412   413   414   415   416   417   418   419