If pid 0 child process pthreadattrinitattr pthread

This preview shows page 1 - 2 out of 2 pages.

if (pid == 0) { /* child process */ pthread_attr_init(&attr); pthread create(&tid, &attr, runner, NULL); pthread_join(tid, NULL); printf("CHILD: value = %d", value); /* LINE C */ } else if (pid > 0) { /* parent process */ wait(NULL); printf("PARENT: value = %d", value); /* LINE P */ } } void *runner(void *param) { value = 27; pthread_exit(0); }
Image of page 1

Subscribe to view the full document.

Problem C . Of these two types of programs: I/O-bound and CPU-bound, which is more likely to have voluntary context switches, and which is more likely to have nonvoluntary context switches? Explain your answer. Problem D. Consider the exponential average formula used to predict the length of the next CPU burst. Associate the following implications a) through e) with assigning the values in 1) and 2), respectively, to the parameters used by the algorithm. a) the most recent burst of the process is given much more weight than the past history associated with the process. b) none of the previous bursts of the process is taken into consideration at all for predicting the length of the next CPU burst. c) the formula always makes a prediction of 150 milliseconds for the next CPU burst. d) after a couple of CPU bursts, the initial prediction value (150 milliseconds) has little impact on predicting the length of the next CPU burst. e) the scheduling algorithm is almost memoryless and simply uses the length of the previous burst as the predicted length of the next CPU burst for the next quantum of CPU execution.
Image of page 2
  • Two '18
  • john
  • FCFS, Dr. Weiying Zhu

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern