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

What was the original purpose/goal in the design of operating systems?

What is today main purpose/goal in the design of operating systems?

Explain why the primary purpose of having an O.S. changed from the 1960 to the 1990s.

Spooling and buffering are both techniques for improving I/O efficiency - but they are different techniques.
     Explain how spooling works WITHOUT mentioning/using buffering

     Explain how buffering works WITHOUT mentioning/using spooling

Buffering is used to overcome what problem?

Spooling is used to overcome what problem?

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?

True False  The purpose of buffering is to compensate for lack of real memory.

True False  The purpose of spooling is to compensate for lack of real memory.

True False  A forked process may share data space with its parent.

True False  A forked process may share code space with its parent.

True False  A forked process may share a File Descriptor Table with its parent

True False  A forked process may share a Run-Time Stack with its parent

Who are the 2 individuals generally credited with the invention of C/Unix?

What is dual mode operation?

Why does a machine need dual mode operation?

What is a context switch?

Why are context switches considered undesirable (to be minimized) by OS designers?

Draw a Unix 'Process State' graph.

Give an example of something that a process might do to initiate a voluntary context switch.  Relate this answer to the Process State graph.

Give an example of something that would cause a process to experience an involuntary context switch.  Relate this answer to the Process State graph.

In C, if you were to write
    int main()
    {
         int x;
         scanf("%d",&x) ;
    }
Why 'in the design of the C language is it necessary to write &x instead of just scanf("%d",x)?  ie. you don't have to explicitly pass the address in other languages like Fortran or Pascal or Cobol.

What is changed by putting '&' at the end of a command line to unix?  Explain this in terms of the shell's behavior.

From the keyboard, how do you signify end of file
    in DOS?
    in Unix?

How do you change the name of a file
    in DOS?
    in Unix?

What is logically wrong with the following block of code?

     if ( fork() == 0 )
     {    printf("Howdy partner");
           args = n;
           execl("/u3/adekock/mypgm", "mypgm", "abc", "xyz", 0);
           printf("Now I'm back");
     }
    .
    .
     ......

When a process resumes execution after returning from a fork(), how can it tell if it is the original process or the new one?

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("                       ",                               );
    }

What is the difference between a blocking function call and a nonblocking call?

What are the important differences between a unix fork() and thr_create()?

What is the function prototype for thr_create()?

Given
    int X[10];
    some appropriate function MyFun
    thread_t Tid;
Write the call to thr_create, which executes MyFun, which accepts the array X as an argument

What is the required function prototype for the function MyFun()?

Write 1 line of code for MyFun that printf's the 3rd integer in the array passed to it.

True  False  A thread may share data space with its parent.

True  False  A thread may share code space with its parent.

True  False  A thread may share a location counter with its parent.

True False  A thread may share a File Descriptor Table with its parent

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

In traditional unix the kernel schedules _____________________ (what entities)

In Solaris the kernel schedules ________________________ (what entities)

Explain why you would expect to find a different frequency of context switches in a purely batch system compared to an interactive system.

If the instruction to set the privilege bit  is a privileged instruction, how does a process in user mode get privileged operations performed?

What is the difference between a pre-emptive scheduler and a time-sliced one?  Which type is used by Unix?  Which type is used by the Solaris thread library?

What does it mean to say that a library or a module is MT-Safe?

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?

How does a thread acquire RAM that is NOT shared with other threads in the task?

Describe how the classical unix scheduler prevents process starvation.

What is the effect of executing
    thr_yield()?
    thr_suspend(...)?
    thr_continue(...)?

What does it mean to say that "mutex_lock(...) is a blocking call"?

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 Argument[10];
       int RtnValue;
    } S1, S2;
 
    thread_t tid;
    void * RtnValue;
    void * FooBar(void * arg);
 
Show the correct way to:
    Store "THREAD 1" in S1's Argument field:
            ___________________________________________
    Pass S1 in the following call:
            thr_create(NULL,NULL,FooBar,_____________________,0,&tid1);
    Output the char-string inside FooBar:
            printf("The String Received = %s\n", _______________________________;
    Store 2 times the thread id into the RtnValue field of arg:
            ______________________ =  __________________________
    Return the struct via a thr_exit:
            thr_exit(  ______________________________ );
    Have main retrieve the returned value:  Use the variable RtnValue since you don't know which thread has exit-ed.
            thr_join(0,&tid, ______________________);
    Have main print which thread exit-ed and the integer returned:
            printf("Thread %d exited with value = %d\n", _____________________, _____________________);