I believe the answer is true :)
the answer is d because depending on your state's laws they can also and endangerment of self and others
Answer:
int sumid=0; /* Shared var that contains the sum of the process ids currently accessing the file */
int waiting=0; /* Number of process waiting on the semaphore OkToAccess */
semaphore mutex=1; /* Our good old Semaphore variable ;) */
semaphore OKToAccess=0; /* The synchronization semaphore */
get_access(int id)
{
sem_wait(mutex);
while(sumid+id > n) {
waiting++;
sem_signal(mutex);
sem_wait(OKToAccess);
sem_wait(mutex);
}
sumid += id;
sem_signal(mutex);
}
release_access(int id)
{
int i;
sem_wait(mutex);
sumid -= id;
for (i=0; i < waiting;++i) {
sem_signal(OKToAccess);
}
waiting = 0;
sem_signal(mutex);
}
main()
{
get_access(id);
do_stuff();
release_access(id);
}
Some points to note about the solution:
release_access wakes up all waiting processes. It is NOT ok to wake up the first waiting process in this problem --- that process may have too large a value of id. Also, more than one process may be eligible to go in (if those processes have small ids) when one process releases access.
woken up processes try to see if they can get in. If not, they go back to sleep.
waiting is set to 0 in release_access after the for loop. That avoids unnecessary signals from subsequent release_accesses. Those signals would not make the solution wrong, just less efficient as processes will be woken up unnecessarily.
Answer:
1. Start
2. Display "Enter three numbers"
3. Input A
4. Input B
5. Input C
6. Sum = A + B + C
7. Display Sum
8. Stop
Explanation:
Line 1 and Line 7 of the algorithm implies the start and end of the algorithm, respectively.
Line 2 prompts user for input of three numbers
Line 3 to 5 accept input from user and these inputs are saved in variables A, B and C
Line 6 adds the three inputs and saves the result in variable Sum
Line 7 displays the value of Sum
Answer:
See explaination
Explanation:
A loop program is a type of program that supports iteration.
It is a conditional statement ptogram that produces its result after a series of iteration or repetition from one loop to the other.
Please go to attachment for the loop program that examines the eight bytes in the words y and z. If a byte is the code for a decimal number, output it to the console. Otherwise, simply ignore it and examine the next byte.