Wednesday, November 13, 2019

Exercise Set One (Chapters 1/2/3)
Problem: Define the essential properties of the following types of operating systems:

         a. Batch b. Interactive c. Time sharing d. Real-Time e. Distributed

Answer:
  1. Batch: Jobs with similar needs are batched together and run through the computer as a group by an operator or automatic job sequencer. Performance is increased by attempting to keep CPU and I/O devices busy at all times through buffering, off-line operation, spooling, and multiprogramming. Batch is good for executing large jobs that need little interaction; it can be submitted and picked up later.
  2. Interactive: Composed of many short transactions where the results of the next transaction may be unpredictable. Response time needs to be short(seconds) since the user submits and waits for the result.
  3. Time sharing: Uses CPU scheduling and multiprogramming to provide economical interactive use of a system. The CPU switches rapidly from one user to another. Instead of having jobs defined by spooled card images, each program reads its next control card from the terminal, and output is normally printed immediately to the screen.
  4. Real-Time: A Real Time system must complete certain processes within a fixed time frame else the system will fail. Certain operations such as information retrieval with an unknown time to complete must be bounded by some known number in order to provide such guarantees. This often eliminates the option of using storage other than fast memory. In a soft real-time system, such deadlines are not guaranteed, but certain processes are given a priority over others with out any notion of a deadline to provide for faster completion.
  5. Distributed Systems: These are systems which do not share common disks memory or clocks. Communication and collaboration is achieved through an inter-connected network. Distributed systems can be autonomous and act as an independent entity as in the case of Network operating systems or can appear as a small part of a much larger whole made up of many separate computers collaborating on the same task.
Problem: What are the differences between a trap and an interrupt? What is the use of each function?
Answer:
    An interrupt is a hardware-generated change-of-flow within the system. An interrupt handler is summoned to deal with the cause of the interrupt; control is then returned to the interrupted context and instruction. A trap is a software-generated interrupt. An interrupt can be used to signal the completion of an I/O to obviate the need for device polling. A trap can be used to call operating system routines or to catch arithmetic errors.
Problem: Which of the following instructions should be privileged?
  1. Set value of timer
  2. Read the clock
  3. Clear memory
  4. Turn off interrupts
  5. Switch form user to monitor mode
Answer:
The following instructions should be privileged

  • Set value of timer
  • Clear memory
  • Turn off interrupts
  • Switch form user to monitor mode
Problem: When are caches useful? What problems do they solve ? What problems do they cause? If a cache can be made as large as the device for which it is caching ( for instance, a cache as large as a disk), why not make it that large and eliminate the device?
Answer:
    Caches are useful when two or more components need to exchange data, and the components perform transfers at differing speeds. Caches solve the transfer problem by providing a buffer of intermediate speed between the components. If the fast device finds the data it needs in the cache, it need not wait for the slower device. The data in the cache must be kept consistent  with the data in the components. If a component has a data value change, and the datum is also in the cache, the cache must also be updated. This is especially a problem on multiprocessor systems where more than one process may be accessing a datum. A component may be eliminated by an equal-sized cache, but only if :
    1. the cache and the component have equivalent state-saving capacity ( that is, if the component retains its data when electricity is removed, the cache must retain data as well) , and
    2. the cache is affordable, because faster storage tends to be more expensive.
Problem:      What are the five major activities of an operating system in regard to process management?
Answer:
  1. The creation and deletion of both user and system processes.
  2. The suspension and resumption of processes
  3. The provision of mechanisms for process synchronization
  4. The provision of mechanisms for process communication
  5. The provision of mechanisms for deadlock handling
Problem:      What are the three major activities of an operating system in regard to memory management?
Answer:
  1. Keep track of which parts of memory are currently being used and by whom
  2. Decide which processes are to be loaded into memory when memory space becomes available
  3. Allocate and deallocate memory space as needed
Problem:     List five services provided by an operating system. Explain how each provides convenience to the users. Explain also in which cases it would be impossible for user-level programs to provide these services.
Answer:
  1. Program Execution: The operating system loads the contents (or sections) of a file into memory and begins its execution. A user-level program could not be trusted to properly allocate CPU time.
  2. I/O operations: Disks, tapes, serial lines, and other devices must be communicated with a very low level. The user need only specify the device and the operation to perform on it, while the system converts that request into device or controller specific commands. User-level programs cannot be trusted to only access devices they should have access to, and to only access them when they are otherwise unused.
  3. File-system manipulation: There are many details in file creation, deletion, allocation, and naming that users should not have to perform. Blocks of disk space are used by files and must be tracked. Deleting a file requires removing the name file information and freeing the allocated blocks. Protections must also be checked to assure proper file access. User programs could ensure neither adherence to protection methods nor could they be trusted to allocate only free blocks and deallocate blocks on file deletion.
  4. Communications: Message passing between systems requires messages be turned into packets of information, sent to the network controller, transmitted across a communications medium, and reassembled by the destination system. Packet ordering and date correction must take place. Again, user programs might not coordinate access to the network device, or they may receive packets destined for other processes.
  5. Error detection: Error detection occurs at both the hardware and software levels. At the hardware level, all data transfers must be inspected to ensure that data have not been corrupted in transit. All data on media must be checked to be sure they have not changed since they were written to the media. At the software level, media must be checked for data consistency; for instance, do the number of allocated and unallocated process- independent (for instance, the corruption of data on a disk), so there must be a global program(the operating system) that handles all types of errors. Also, by having errors processed by the operating system, processes need not contain code to catch and correct all the errors possible on a system.


Chapter 3

Problem 3.1: Describe the differences among short-term, medium-term, and long-term scheduling.
Answer:
    • Short-term:(CPU scheduler)- selects from jobs in memory, those jobs which are ready to execute, and allocates the CPU to them.
    • Medium-term - used especially with time-sharing systems as an intermediate scheduling level. A swapping scheme is implemented to remove partially run programs from memory and reinstate them later to continue where they left off.
    • Long-term (job scheduler) - determines which jobs are brought into memory for processing.
    The primary difference is in the frequency of their execution. The short-term must select a new process quite often. Long-term is used much less often since it handles placing jobs in the system, and may wait a while for a job to finish before it admits another one.
Problem 3.2: Describe the actions taken by a kernel to switch context

         a. Among threads  b. Among processes

Answer:

  1. The thread context must be saved(registers and accounting if appropriate), and another thread's context must be loaded.
  2. The same as (a), plus the memory context must be stored and that of the next process must be loaded.

No comments:

Post a Comment