Handed out Tuesday, January 8, 2019
Due 9:00 PM, Friday, January 11, 2019
Describe how new processes come into being: how do existing processes make new ones, and what is the operating system's role? You only need a few sentences.
This is a brief C exercise. (The labs will require comfort and fluency in C.) Below is a snippet of code:
void op1(int a, int b) { a = a + b; } void op2(int* a, int* b) { *a = *a + *b; } int main() { int a = 1, b = 1, c = 1, d = 1; op1(a, b); op2(&c, &d); return 0; }
What are the values of a
, b
,
c
, and d
right before the program exits?
Since the purpose of this exercise is to build your skills, you should
do this problem without compiling and running the program.
Operations on files, such as read, write, and close, are typically implemented as system calls. Describe two of the benefits of having these operations managed by the operating system instead of individual processes.
Below is another snippet of C code:
int a[5]; a[0] = 0; a[1] = 10; a[2] = 100; //COMMENT 1 a[3] = *a + 2; a[4] = *(a + 2); //COMMENT 2
What are the values stored in the array a
when the program reaches COMMENT 1? (Do we know all
of the values?) What about when the program reaches COMMENT 2?
Write your answers in a text file. Name the file answers.txt and upload it on GauchoSpace.
Last updated: 2019-01-15 09:52:45 -0800 [validate xhtml]