homework-1 - CSE 421/521 – Operating Systems Fall 2011...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE 421/521 – Operating Systems Fall 2011 - Homework Assignment #1 The due date is: September 15th, Thursday, before the class (9:30am). Late submission is not allowed. int main(int argc, char *argv) P{ roblem 1: if (argc != 2) exit(0); pid_t pid; int i, a, b, fib; int n = atoi(argv[1]); Problem 2: / fork switches used for and What are *context another process */ what does a typical context switch involve? pid = fork(); Compare processes versus threads in terms of context switch operation and overhead associated { /* it. if (pid < 0) with error occurred */ Problem 3: fprintf(stderr, "Fork Failed\n"); exit(-1); } else if (pid == 0) { /* child process */ if (n == 1) printf("0\n"); else if (n == 2) printf("0, 1\n"); else if (n > 2) { a = 0; b = 1; printf("0, 1,"); for (i = 3; i < n; i++) { fib = a + b; printf("%d,",fib); a = b; b = fib; } Problem 4: printf("%d\n",a+b); Discuss the tradeoffs } between user and kernel threads. } (a)lsehat are the advantages and*/ e W { /* parent process disadvantages of each? /* parent will wait for the child to complete */ wait(NULL); (b) Assume we can make system calls as fast as procedure calls using some new hardware mechanism. Would this make one kind of thread exit(0); clearly preferable over the other? Explain briefly. } } Problem 5: ...
View Full Document

{[ 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