Assignment4-Rennie Ramlochan -

Embed Size (px)

Citation preview

  • 8/11/2019 Assignment4-Rennie Ramlochan -

    1/7

    http://sundaros.blogspot.com/2010/09/old-test-i.html

    http://quizlet.com/26336566/csci-451-ch1-5-book-qx-answers-flash-cards/

    1What is the distinction between spatial locality and temporal locality?

    Spatial locality refers to the tendency of execution to involve a number of memory locations that areclustered. Temporal locality refers to the tendency for a processor to access memory locations that havebeen used recently. Spatial locality is generally exploited by using larger cache blocks and byincorporating prefetching mechanisms (fetching items of anticipated use) into the cache control logic.

    Temporal locality is exploited by keeping recently used instruction and data values in cache memory andby exploiting a cache hierarchy.

    Consider the following code fragment:for ( int i = 0; i < 20; i++ ) {for ( int j = 0; j < 10; j++ ) {a[i][j] = 0;}}a) Give an example of spatial locality in the code, if there is one.Spatial locality occurs when the process uses nearby memory contents. This occurs when the array entries areaccessed more or less sequentially within the inner loop. One could also argue spatial locality occurs when theinstructions in the loop code are executed.

    b) Give an example of temporal locality in the code, if there is one.Temporal locality occurs when the same memory location is used repeatedly over some relatively short timeinterval. This occurs when the loop index variables i and j are repeatedly incremented. The repeated accessesto a[i], for a particular value of i, occur within a relatively short time.

  • 8/11/2019 Assignment4-Rennie Ramlochan -

    2/7

    2.In virtually all systems that include DMA modules, DMA access to main memory is given higher prioritythan processor access to main memory. Why?

    If the processor is held up in attempting to read or write memory, usually no damageoccurs, except a slight loss of time. But a DMA transfer may be from/to a device that issending/receiving data in a continuous time sensitive stream (e.g., a network port, or atape drive) and cannot be stopped without the loss of data.

    DMA has higher priority because the CPU accesses the memory very frequently andthe DMA can starve, waiting for the bus to be free.

    3.A computer has a cache, main memory, and a disk used for virtual memory. If a referenced

    word is in the cache, 20 ns are required to access it. If it is in main memory but

    not in the cache, 60 ns are needed to load it into the cache (this includes the time to

    originally check the cache), and then the reference is started again. If the word is not

    in main memory, 12 ms are required to fetch the word from disk, followed by 60 ns to

    copy it to the cache, and then the reference is started again. The cache hit ratio is 0.9

    and the main-memory hit ratio is 0.6.What is the average time in ns required to access

    a referenced word on this system? Question: is this design any good?

    Answer: There are three cases to consider:

    Location of referenced word Probability Total time for access in nsIn cache 0.90 20

    Not in cache, but in main memory (0.10)(0.6) = 0.06 60 + 20 = 80 Not in cache or main memory (0.10)(0.4) = 0.04 12ms + 60 + 20 = 12000080

    So the average access time would be:

  • 8/11/2019 Assignment4-Rennie Ramlochan -

    3/7

    Avg = (0.90)(20) + (0.06)(80) + (0.04)( 12000080) = 480026 nsDesign is no good. Average access time is over 24000 (480026/20) time cache access time,

    4Explain the distinction between a real address and a virtual address.

    A virtual address refers to a memory location in virtual memory. That location is on disk and at

    some times in main memory. A real address is an address in main memory.

    program references a word by means of a virtual address consisting of a page number and an offsetwithin the page. Each page of a process may be located anywhere in main memory. The paging systemprovides for a dynamic mapping between the virtual address used in the program and a real address, orphysical address, in main memory.

    Q-9}. Explain the difference between a monolithic kernel and a microkernel.

    Ans. Monolithic kernel:Earlier in this type of kernel architecture, all the basic system serviceslike process and memory management ,interrupt handling etc.where packaged in to singlemodule in kernel space. This type of architecture led to some serious drawbacks like

    1)Size of kernel ,which was huge

    2)Poor maintainability.

    Which means bug fixing or addition of new features resulted in recomplimention of the wholekernel which could consume hours.

    In a modern day approach to monoloithic architecture, the kernel consist of different moduleswhich can be dynamically loaded and unloaded.This moduler approach, maintainability of kernel

    become very easy as only the concerned module needs to be loaded and unloaded every timethere is a change or bug mix in a particular module.So there is no need to bring down andrecompile the whole kernel for a smallest bit of change.

    Microkernal: The architecture measurly caters to the problem of ever growing size of kernel codewhich we could not control in the monolithic approach.

    This architecture allows some basic services like devices driver management, protocol stacs filesystem etc to run in user space. This reduces the kernel code size and also increases the sequrityand stability of OS as we have the bare minimum code running in

    kernel. So , if suppose a basic services like network service crashes due to buffer overflow,thenonly the networking services memory would be corrupt ed living the rest of the system steelfunctional.

  • 8/11/2019 Assignment4-Rennie Ramlochan -

    4/7

  • 8/11/2019 Assignment4-Rennie Ramlochan -

    5/7

    The system operator can review this quantity to determine the degree of "stress" on the system. Byreducing the number of active jobs allowed on the system, this average can be kept high. A typicalguideline is that this average should be kept above 2 minutes [IBM86]. This may seem like a lot, but itisn't.

    2.2 An I/O-bound program is one that, if run alone, would spend more time waiting forI/O than using the processor. A processor-bound program is the opposite. Suppose ashort-term scheduling algorithm favors those programs that have used little processortime in the recent past. Explain why this algorithm favors I/O-bound programs andyet does not permanently deny processor time to processor-bound programs.

    . I/O-bound processes use little processor time; thus, the algorithm will favorI/O-bound processes.b. if CPU-bound process is denied access to the processor- the CPU-bound process won't use the processor in the recent past.- the CPU-bound process won't be permanently denied access.

    2.9 Explain the difference between a monolithic kernel and a microkernel.

    monolithic kernel A large kernel containing virtually the complete operating system, includingscheduling, file system, device drivers, and memory management. All the functional componentsof the kernel have access to all of its internal data structures and routines. Typically, a monolithic kernelis implemented as a single process, with all elements sharing the same address space.

    3333microkernel A small privileged operating system core that provides process scheduling, memorymanagement, and communication services and relies on other processes to perform some of thefunctions traditionally associated with the operating system kernel.

    Monolithic Kernel;

    1. Kernel is a single large block of code.2. Runs as single process within a single address space.3.Virtual any procedure can call any other procedure.4.If anything is changed, all modules and functions must be recompiled and relinked and system

  • 8/11/2019 Assignment4-Rennie Ramlochan -

    6/7

    rebooted.5. Difficult to add new device driver of file system functions.

    Microkernel;

    1.Only core OS functions are in the kernel.2.Less essential services and applications are built on microkernel and execute in user mode.3.Simplifies implementation, provides flexibility and better suited for distributed environment.

    3.4 What does it mean to preempt a process?Reclaiming a resource from a process before the process has finishedusing it. 3.5 What is swapping and what is its purpose?A process that interchanges the contents of an area of main storagewith the contents of an area in secondary memory.

    3.2 Consider a computer with N processors in a multiprocessor configuration.a. How many processes can be in each of the Ready, Running, and Blocked states atone time?b. What is the minimum number of processes that can be in each of the Ready,Running, and Blocked states at one time?

    a. There can be N processes in running state. The number of processes in ready and blocked statedepends on the size of "ready list" and "blocked list".

    b. The minimum number of processes can be 0, if the system is idle and there are no blocked jobs or noready jobs.

  • 8/11/2019 Assignment4-Rennie Ramlochan -

    7/7

    3.6 Consider the state transition diagram of Figure 3.9b. Suppose that it is time for theOS to dispatch a process and that there are processes in both the Ready state and theReady/Suspend state, and that at least one process in the Ready/Suspend state hashigher scheduling priority than any of the processes in the Ready state.Two extreme

    policies are as follows: (1) Always dispatch from a process in the Ready state, to minimizeswapping, and (2) always give preference to the highest-priority process, eventhough that may mean swapping when swapping is not necessary. Suggest an intermediate

    policy that tries to balance the concerns of priority and performance

    Penalize the Ready, suspend processes by some fixed amount, such as one or two priority levels

    Then a Ready/Suspend process is chosen next only if it has a higher priority than the highest-priority Ready process by several levels of priority.