Sample Exercises for Quiz 5

Runtime Segments & Linking, SPARC machine instructions,
I/O, Memory Management, Traps/Exceptions

If we have not covered a particular set of topics in class, you will not
be help responsible for them on this Quiz, but probably for the Final.

Recursion!

Name the 5 basic Unix C Runtime sections and describe the function of each
section.  What sections are part of the executable file on disk.

Starting with a C source file, list the order of each of the main parts of
the compilation and loading process through to the point of execution of the
program. 

What are the main functions of the linkage editor/linker?  the loader?

Given the following program, name where each variable/constant/memory
allocation is stored in the C Runtime environment.  What is the
scope/visibility and lifetime of each?

	extern int external_global;

        int global1 = 5;
        int global2;

        static int external_static1 = 7;
        static int external_static2;

        extern int foo( int * );  /* function prototype */

        int
        main( int argc, char *argv[] ) {
           char *chPtr = NULL;
           int *iPtr;
           int (*ptf)( int * );

           static int internal_static1 = 11;
           static int internal_static2;

           iPtr = (int *) malloc( 40 );

           chPtr = "Hello World";

           ptf = foo;           /* (*ptf)( iPtr ); to make the function call */

           return 0;
        }

What does the keyword static mean in terms of storage allocation
location and scoping in C?
external static variable / internal static variable / static function.

Describe some of the differences between static and dynamic linking.  What
are some advantages and disadvantages of each.

Be able to encode and decode SPARC assembly instructions given tables
detailing the bit patterns for the various opcode/register mappings.

How many bits are needed to encode one of the 32 named registers (%g0-%g7,
%i0-%i7, %l0-%l7, %o0-%o7)?

How many bits are available in a format 3 instruction to encode an
immediate constant value?  Which operand(s) is/are allowed to be immediate
constants?

When must you use a set instruction vs. a mov instruction
and why?

The main cache write policies are Write _______ and Write _____ .
What are the characteristics of each.

What does the keyword volatile do?

Why can't you use an internal static variable in a multi-threaded
environment (why is it not thread-safe).

Why have separate Instruction and Data caches.

What is the relative memory hierachy of the various components of a
computer system that can store/hold data?

What is DMA?  What is the difference between burst mode and cycle stealing?

What are the three basic types/mechanism of performing I/O we discussed in
class?

What are the two main types/levels of CPU involvement with performing I/O
we discussed in class?

What is a context switch?  Under what conditions does one occur?
Differentiate between a partial context switch and a full context/process switch.

What kinds of information is kept in the PSR?

What is User mode vs. Supervisor/Kernel mode?  What are some of the
differences/functions of the upper-half and lower-half of the kernel?

What is the difference between
	Operator Precedence
	Operator Associativity
	Order of Evaluation of Operands

Write a short C program to display the approximate value of the Frame Pointer
in main().
Hint: allocate a single local (int) variable.
Do the same in SPARC Assembly.

Write a short C program to display the approximate value of the Stack Pointer
in main().
Hint: allocate a single local (int) variable.
Do the same in SPARC Assembly.

Write a short C program to display the approximate virtual memory location of
the first instruction of main() in main().
Do the same in SPARC Assembly.

Write a short C program to display the approximate virtual memory location of
the start of the Heap. 
Hint: dynamically allocate a single byte in the Heap.
Do the same in SPARC Assembly.

Write a short C program to display the approximate virtual memory location of
the start of the Data segment. 
Do the same in SPARC Assembly.

Write a short C program to display the approximate virtual memory location of
the start of the BSS segment. 
Do the same in SPARC Assembly.

Basic GDB debugging commands.


If some of these topics have not been covered yet they won't be on Quiz 5
but will be on the Final:

The MMU maps ______ addresses to ______ addresses.

The ______ _______ register holds the Integer Condition Code bits, the
Current Window Pointer bits, and the Process Interrupt Level bits.

What does TLB stand for?

What is the function of the TLB?  What type of cache is the TLB?

If there is a miss in the TLB a ______ _____ occurs, because the
page was not found in main memory.

What is "thrashing?"

When combining Paging and Segmentation, is paging done within segments or
segmentation done within pages?


What question would you most like to see on the Final Exam?