a) [6 points] Write an ITERATIVE function that returns the count of the number of nodes in the list. Code in the language of your choice and declare your data structure.
b) [8 points] Repeat using RECURSION.
c) [6 points] State which solution is better and give a brief justification.
const int N = 5;
Semaphore A = N; // initial value of the semaphore
Semaphore B = 0; // initial value of the semaphore
int buffer[0..N-1];
int i = -1;
Producer: Consumer:
while (true) { while (true) {
wait(A); wait(B);
i = i + 1; ch = buffer[i]; // consumed character
buffer[i] = ch; // produced character i = i - 1;
signal(B); signal(A);
} }
a) What are the main differences between this version and the standard version?
b) Demonstrate that the code is faulty because it can accidentally re-consume the same
character from the buffer.
Use any combination of diagrams, charts, description, line numbers, etc.
c) How could this fault in b) be prevented?
a) [5 points] Define the LRU algorithm.
b) [10 points] Describe the second-chance page replacement algorithm, sometimes known as the "clock" algorithm.
c) [5 points] Describe the generalized form of this algorithm where a record of past reference bits
are maintained.
To:Henry.James@csueastbay.edu Mark.Twain@sybase.com From:Rudyard.Kipling@cisco.com Subject:Here is my subject Body: This is an example email. Note that it can be addressed to multiple users. The Subject contains one line of text (a sentence), consisting of words, but the Body can contain multiple sentences, even blank sentences. This is the last line of the Email message.
Notes:
1. Examples of the terminal address are:
Henry.James@csueastbay.edu
Mark.Twain@sybase.com
Rudyard.Kipling
2. Examples of the terminal word of text are:
Here
multiple
3. To:, From: always have some contents.
4. Subject:, Body: may be empty.
5. Do not worry about spaces or newlines: white space is ignored.
Read the description of the language carefully. Construct a BNF grammar for this subset of the Email definition language. Do not do use any extensions such as EBNF or other BNF variants.
You may choose 3A or 3B, but not both.
over the alphabet S={0, 1}.
|
is similar to a standard Turing machine model M in all respects except that its transition function is defined as
|