QuestionQuestion

1, What is the difference between a mode switch and a process switch. Also, give an example for each type of switch.

2. A process can only be in one event queue at a time.
a. Is it possible that you would want to allow a process to wait on more than one event at the same time? Provide an example.
b. In that case, how would you modify the queueing structure of the figure to support this new feature?

3. Search online the manual of the system call fork(). Assume that you have executed the following C program:
main ()
{ int pid;
pid = fork ();
printf (ā€œ%d \nā€, pid);
}
What are the possible outputs, assuming the fork succeeded?

4. Many current language specifications, such as for C and C++, are inadequate for multithreaded programs. This can have an impact on compilers and the correctness of code, as this problem illustrates. Consider the following declarations and function definition:

int global_positives = 0;
typedef struct list {
struct list *next;
double val;
} * list;

void count_positives(list l)
{
list p;
for (p = l; p; p = p -> next)
if (p -> val > 0.0)
++global_positives;
}

Now consider the case in which thread A performs
count_positives(<list containing only negative values>);
while thread B performs
++global_positives;

a. What does the function count_positives() do?
b. The C language only addresses single-threaded execution. Does the use of two parallel threads create any problems or potential problems?

5. Discuss the advantages of multi-threading over multiprocessing with examples.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

A process switch is also called as context switch and represents the situation when the processor toggles from one thread to another. In these conditions the values of CPU registers and instruction pointer are saved. When it is needed to be executed the next task, the registers and instruction pointer for it are loaded into the processor, while the old task is no longer executed. However its state is also saved in memory for the moment when the OS kernel decides that it must be executed again. Such switch mode (context) can occur both by hardware or software. A hardware interrupt can interfere from a device like peripherals or system timer and causes the execution of interruption routine....

By purchasing this solution you'll be able to access the following files:
Solution.docx.

$28.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Operating Systems Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats