Semaphore waiting lists are often implemented as FIFO queues. Could they be implemented as stacks? What problems would this implementation cause?
As discussed in class, a monitor is the result of a fusion between shared data and the functions (methods) that operate on this data. The code below makes the assumption that a monitor can declared just like a class in C++. This is a hypothetical situation.
Consider the following solution to the dining philosopher's problem: monitor Chopsticks { private: // variable declarations go here public: void pickup( int philosopherNumber ); void putdown( int philosopherNumber ); }; Chopsticks::pickup( int philosopherNumber ) { // function body goes here } Chopsticks::putdown( int philosopherNumber ) { // function body goes here } //-------------------------------------------- Chopsticks chopsticks; void philosopher( int n ) { while ( true ) { think(); chopsticks.pickup( n ); eat(); chopsticks.putdown( n ); } }
Write declarations for the shared variables needed by the monitor and the pseudo-code for the bodies of the two monitor functions. Be sure that your solution is deadlock and starvation free.
Write a solution of the dining philosophers problem that uses message passing and a central coordinating process the the philosophers communicate with when they want to start or stop eating.
Do problem 6.9 in the text: Demonstrate that monitors, conditional critical regions, and semaphores are all equivalent, insofar as the same types of synchronization problems can be implemented with them.
Hint: Show that if one of the mechanisms is available then another can be implemented. Then show that if that mechanism is available then the third can be implemented. Finally, show that if the third is available then the first can be implemented. That is: if each of the mechanisms is represented by one of the letters A, B or C, show thatA => B => C => A
which shows that these mechanisms are all logically equivalent.
Suppose that an operating system supported message passing, but did not directly support semaphores. Show how you could implement semaphores by the use of suitable library routines. (Hint: Use a semaphore manager process that receives wait() and signal() messages from other processes).
(Optional for extra credit) Your answers to the last two problems show that message passing is at least as powerful as the other three process coordination primitives that rely on shared memory. (Given message passing, you could implement semaphores, etc.) Show how you could implement the message passing primitives send() and receive() on a shared memory system using any of the other three schemes (your choice).
The converse of an inverse is the contrapositive, which is logically equivalent to the original conditional.
A Contrapositive statement is logically equivalent.
The conditional statement "If A then B" is equivalent to "Not B or A" So, the inverse of "If A then B" is the inverse of "Not B or A" which is "Not not B and not A", that is "B and not A",
Contrapositive
a conditional and its contrapositive
This is not always true.
This would be logically equivalent to the conditional you started with.
The statement "if not p, then not q" always has the same truth value as the conditional "if p, then q." They are logically equivalent.
The statement is false. The conditional statement "If P, then Q" and its converse "If Q, then P" are distinct statements, but the negation of the converse would be "It is not the case that if Q, then P." Thus, the conditional and the negation of the converse are not equivalent or directly related.
The law of contrapositive states that a conditional statement of the form "If P, then Q" (P → Q) is logically equivalent to its contrapositive, "If not Q, then not P" (¬Q → ¬P). This means that if the original statement is true, the contrapositive must also be true, and vice versa. This principle is widely used in mathematical proofs and logical reasoning to demonstrate the validity of arguments.
Le mode conditionnel is a French equivalent of the incorrect English phrase "the conditional tense." The masculine singular definite article, noun, and adjective translate literally and properly into English as "the conditional mood," whose tense may be present or past. The pronunciation will be "luh muhd ko-dee-tsyo-nel" in French.
It is a logical conditional statement which states that if some condition, a, is satisfied then another condition, b, must be satisfied. If a is not satisfied then we can say nothing about b.An equivalent statement, in a non-conditional form, is that~b or a must be TRUE, where ~b denotes not b.