Page 262 - DCAP403_Operating System
P. 262

Unit 13: Case Study: Linux




          In a multiprocessor system, hopefully, all of the processors are busily running processes. Each   Notes
          will run the scheduler separately as its current process exhausts its time-slice or has to wait for

          a system resource. The first thing to notice about an SMP system is that there is not just one idle

          process in the system. In a single processor system the idle process is the first task in the task
          vector, in an SMP system there is one idle process per CPU, and you could have more than one
          idle CPU. Additionally there is one current process per CPU, so SMP systems must keep track of
          the current and idle processes for each processor.
          In an SMP system each process’s task_struct contains the number of the processor that it is
          currently running on (processor) and its processor number of the last processor that it ran on
          (last_processor). There is no reason why a process should not run on a different CPU each time
          it is selected to run but Linux can restrict a process to one or more processors in the system using
          the processor_mask. If bit N is set, then this process can run on processor N. When the scheduler
          is choosing a new process to run it will not consider one that does not have the appropriate bit
          set for the current processor’s number in its processor_mask. The scheduler also gives a slight
          advantage to a process that last ran on the current processor because there is often a performance
          overhead when moving a process to a different processor.

          13.5 Memory Management

          The memory management subsystem is one of the most important parts of the operating system.
          Since the early days of computing, there has been a need for more memory than exists physically
          in a system. Strategies have been developed to overcome this limitation and the most successful
          of these is virtual memory. Virtual memory makes the system appear to have more memory than
          it actually has by sharing it between competing processes as they need it.
          Virtual memory does more than just make your computer’s memory go further. The memory
          management subsystem provides:
          Large Address Spaces: The operating system makes the system appear as if it has a larger amount
          of memory than it actually has. The virtual memory can be many times larger than the physical
          memory in the system.
          Protection: Each process in the system has its own virtual address space. These virtual address
          spaces are completely separate from each other and so a process running one application
          cannot affect another. Also, the hardware virtual memory mechanisms allow areas of memory
          to be protected against writing. This protects code and data from being overwritten by rogue
          applications.
          Memory Mapping: Memory mapping is used to map image and data files into a processes address


          space. In memory mapping, the contents of a file are linked directly into the virtual address space
          of a process.
          Fair Physical Memory Allocation: The memory management subsystem allows each running
          process in the system a fair share of the physical memory of the system.

          Shared Virtual Memory: Although virtual memory allows processes to have separate (virtual)
          address spaces, there are times when you need processes to share memory. For example there
          could be several processes in the system running the bash command shell. Rather than have
          several copies of bash, one in each processes virtual address space, it is better to have only one
          copy in physical memory and all of the processes running bash share it. Dynamic libraries are
          another common example of executing code shared between several processes.
          Shared memory can also be used as an Inter Process Communication (IPC) mechanism, with two
          or more processes exchanging information via memory common to all of them. Linux supports
          the Unix TM System V shared memory IPC.
          Before considering the methods that Linux uses to support virtual memory it is useful to consider
          an abstract model that is not cluttered by too much detail.



                                           LOVELY PROFESSIONAL UNIVERSITY                                   255
   257   258   259   260   261   262   263   264   265   266   267