






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







(1) This exam is closed book, closed notes, and closed neighbor. No calculators or other references are permitted. Violation of any of these rules will be considered academic dishonesty.
(2) You have 120 minutes to complete this exam. If you finish early, you may turn in your exam at the front of the room and leave. However if you finish during the last ten minutes of the exam please remain seated until the end of the exam so you don't disturb others. Failure to follow this direction will result in points being deducted from your exam.
(3) Write all answers on the exam sheets. If you need additional paper, we will provide it. Make sure your name is on any additional sheets. You must submit any additional sheets you are given. If a question is continued to another page, it must be clearly indicated both on the page it is continued from and on the page it is continued to.
(4) Partial credit will be given for most questions assuming we can figure out what you were doing.
(5) Please write neatly. Print your answers, if that will make your handwriting easier to read. If you write something, and wish to cross it out, simply put an X through it. Please clearly indicate if your answer continues onto another page.
1.) [12 points] Short Answer Questions, Write a short paragraph – complete sentences and thoughts -- to answer each of the questions given here.
a) Describe the parts of and the purpose of the Process Control Block (PCB).
b) Describe Ahmdal’s Law and how it can be used to make your code more efficient.
2.) [19 points] Write functions to do each of the following tasks using the following types:
#define TSIZE 27
typedef struct Node { int *key; int *value; struct Node *next; } Node;
typedef Node* Pntr;
typedef Pntr[TSIZE] TArr;
typedef struct{ int size; /* total number of elements in table / TArr data; / actual data of the table / } Table; / an empty table has a 0 for the size and all pointers in the array as NULL */
a) Write the function which will completely empty the hash table (leaving an empty table). You must be sure there are no memory leaks, and you do not have any helper functions provided that will clean up parts of the table. The function returns 0 if there were nodes to delete or -1 if the table is empty or any error occurred. FUNCTION CALLED: Table x; /other code here filling the table/ cleantable(&x); PROTOTYPE: int cleantable(Table*);
b) Write a function that creates a new chained (bucket) hash table which is an exact independent copy of the original. The first parameter passes in the hash table to be copied while the second passes back the new copy that you must completely create. The function should not modify the original table. It should insert all elements into the same hash line on the table (it does not need to rehash), but the value field should be increased by one. Since the hash was based on the key field rather than the value, changing the value field will not change where it is hashed to. It should return as the return value of the function 0 if the table is completely empty (but any empty copy was made anyway), or the number of elements in the largest chain of the hash table if there are one or more elements in the table, or a -1 for any type of failure.
FUNCTION CALLED: Table x,y=NULL; /other code filling x; y is still NULL;*/ copyhash(x,y);
PROTOTYPE: int copyhash(Table, Table *);
4.) Assume you wish to use a binary search tree to store a list of three functions for each of several different people.
a) [8 points] You need to define the types needed to do this. Each function returns a float, and takes as parameters an array of integers and an integer that specifies the number of used elements in that array. You only need to create the types necessary for storage as described below.
b) [12 points] These questions continue from the previous page. Using the types you just defined, give prototypes for the following functions:
5.) [12 Points] For each of the following blanks, tell what the value of the variable would be immediately after the line containing the blank is executed or if you don’t know an exact numerical value, describe what value it would be in English or write “???” for any values requested that you would not know the value of (this includes values you can not be sure of) or write “DANGER” if referencing that variable to find out its value could cause a segmentation fault or other runtime error.
6.) [10 Points] For each of the following fill in the correct word from this list (not all words in the list will be used and a word in the list can be used more than once.
cylinder cache epoch
pipeline stall AVL tree normalization
branch prediction code motion dynamic memory
multi-programming loop splitting interval time
best fit allocation instruction level pipelining first fit allocation
register spilling column major order superscalar processors
array descriptor row major order NONE OF THOSE LISTED
a) ____________________________ The processor makes an educated guess as to which instruction will be done next in order to start the processing of that selected command before it knows for sure if it will be the next command done.
b) _____________________________ Changing the source code so that any statements that do not need to be done on each and every iteration are no longer inside the loop and the application will take less time to run.
c) ______________________________ Time is measured in the number of seconds since this selected time.
d) _____________________________ The algorithm says to find the unit closest in size without being smaller than what is requested and then take the portion of that block as needed.
e) ______________________________ The instruction is broken into a series of individual tasks such as fetching the instruction, decoding the instruction and executing the instruction so that different steps can be done by different functional units at the same time.