Computer Science 284

Introduction to Operating Systems

Question Pool for Exam 1

CONSTANTS IN THESE QUESTIONS MAY CHANGE WHEN THE QUESTION IS INCLUDED ON THE EXAM
  1. What was the original purpose/goal in the design of operating systems?
  2. What is today main purpose/goal in the design of operating systems?
  3. Explain why the primary purpose of having an O.S. changed from the 1960 to the 1990s.
  4. What is the meaning of the address store in a location-counter?
    Spooling and buffering are both techniques for improving I/O efficiency - but they are different techniques.
  5. Explain how spooling works WITHOUT mentioning/using buffering
  6. Explain how buffering works WITHOUT mentioning/using spooling
  7. Buffering is used to overcome what problem?
  8. Spooling is used to overcome what problem?
  9. Early system designers wanted to increase CPU efficience by increasing the number of programs in memory from 1 to some small n.  Explain the reasoning behind that goal; ie. why would having more programs in RAM increase total CPU efficiency?
  10. True False  The purpose of buffering is to compensate for lack of real memory.
  11. True False  The purpose of spooling is to compensate for lack of real memory.
  12. True False  A forked process may share data space with its parent.
  13. True False  A forked process may share code space with its parent.
  14. True False  A forked process may share a Run-Time Stack with its parent
  15. Who are the 2 individuals generally credited with the invention of C/Unix?
  16. What is dual mode operation?
  17. Why does a machine need dual mode operation?
  18. What is a context switch?
  19. What is a mode switch?
  20. Why are context switches considered undesirable (to be minimized) by OS designers?
  21. Draw a Unix 'Process State' graph.
  22. Give an example of something that a process might do to initiate a voluntary context switch.  Relate this answer to the Process State graph.
  23. Give an example of something that would cause a process to experience an involuntary context switch.  Relate this answer to the Process State graph.
  24. In C, you would write the following to read an integer into x.
     int main() 
     {
        int x; 
        scanf("%d",&x) ; 
     } 
     What 'in the design of the C language makes it necessary to write &x instead 
     of just scanf("%d",x)? i.e. why do you not have to explicitly pass the address 
     in other languages like Fortran or Pascal or Cobol. 
  25. What is changed by putting '&' at the end of a command line to unix?  Explain this in terms of the shell's behavior.
  26. From the keyboard, how do you signify end of file in Unix?
  27. How do you change the name of a file in Unix?
  28. What is logically wrong with the following block of code?
  29. if ( fork() == 0 )
    {    printf("Howdy partner"); 
         args = n;        
         execl("/u3/adekock/mypgm", "mypgm", "abc", "xyz", 0);        
         printf("Now I'm back");
    }
    else
    {      ...... 
  30. When a process resumes execution after returning from a fork(), how can it tell if it is the original process or the new one?
  31. GIVEN: a command line entry like - 
             a.out XX YY ZZ 
    complete the def. of main() and the printf to print the YY argument 
    int main(                                                 ) 
    { 
        printf("________________________",_______________________________); 
    } 
  32. What is the difference between a blocking function call and a nonblocking call?
  33. What are the important differences between a unix fork() and thr_create()?
  34. What is the function prototype for thr_create()?
  35. Given
        int X[10];
        some appropriate function MyFun
        thread_t Tid;
    Write the call to thr_create, which executes MyFun. Pass the array X as the argument for MyFun.
  36. What is the required function prototype for the function MyFun()?
  37. Write 1 line of code for MyFun that printf's the 3rd integer in the array passed to it.
  38. True  False  A thread may share data space with its parent.
  39. True  False  A thread may share code space with its parent.
  40. True  False  A thread may share a location counter with its parent.
  41. True False  A thread may share a File Descriptor Table with its parent
  42. When a new thread is created, several options may be selected.  What is the effect of each of the following:
       THR_SUSPENDED
       THR_NEW_LWP
       THR_DETACHED
       THR_BOUND
  43. In traditional unix the kernel schedules _____________________ (what entities)
  44. In Solaris the kernel schedules ________________________ (what entities)
  45. Explain why you would expect to find a different frequency of context switches in a purely batch system compared to an interactive system.
  46. If the instruction to set the privilege bit  is a privileged instruction, how does a process in user mode get privileged operations performed?
  47. What is the difference between a pre-emptive scheduler and a time-sliced one?
  48. What does it mean to say that a library or a module is MT-Safe?
  49. A kernel level context switch may or may not be  required to switch between user level threads (within the same process). What determines whether the kernel is involved or not when switching between threads?
  50. How does a thread acquire RAM that is NOT shared with other threads in the task?
  51. What is the effect of executing
  52. can ALL of the threads within a process be suspend()ed, then later thr_continue(...)ed?
  53. What does it mean to say that "mutex_lock(...) is a blocking call"?
  54. Why does the man page, for thr_exit(VALUE), say that VALUE should not reference any variable local to the calling thread?

    Assume that you have globally defined
        struct Shared
        { char Name[10];
           int Value;
        } S1, S2;

    thread_t tid;
        void * RtnValue;
        void * FooBar(void * arg);   // For this problem, arg will point to an instance of struct Shared

    Show the correct way to:

  55. Store "THREAD 1" in S1's Name field:
    __________________________________________________

  56. Pass S1 in the following call:
    thr_create(NULL,NULL,FooBar,_____________________,0,&tid1);

  57. From within the function FooBar, print the Name that was passed inside the struct:

  58. printf("The Name Received = %s\n", _____________________________________________;

  59. store 2 times the thread id into the Value field of arg:
     ______________________ =  __________________________

  60. return the struct via a thr_exit:
    thr_exit(  ______________________________ );

  61. Have main retrieve the returned value:  Use the variable RtnValue since you don't know which thread has exit-ed.

    thr_join(0,&tid, ______________________);

  62. Have main print which thread exit-ed and the integer returned:

    printf("Thread %d exited with value = %d\n", _____________________, _____________________);

  63. What is an atomic operation?
  64. What is the difference between mutex_lock and mutex_trylock?
  65. The word 'mutex' is short for ______________________________________.
  66. What makes a portion of code within a function the 'critical section'?
  67. What would you expect to see (what instructions) surrounding the 'critical section' code?
  68. If a mutex_t M is associated with locking a variable counter, whos responsibility is it to make sure that counter isn't used without 1st locking M?
  69. What is a spin-lock?
  70. What is an alternative to spin-locking?
  71. Explain under what circumstances a spin lock might be more efficient than the alternative.
  72. Explain under what circumstances a spin lock might be less efficient than the alternative.
  73. Under Solaris 2 running on a uniprocessor, threads waiting for a lock always sleep rather than spin.     Why is this true (and reasonable)?
  74. What is a critical section i.e. what makes a section 'critical'?
  75. What is the difference between a mutex_t and a sema_t?
  76. What is the difference between mutex_lock and mutex_trylock?
  77. Under what conditions must a sema_t be initialized?