CSCI-UA.0202 Spring 2015 Homework 1: C review, Processes

Handed out Thursday, January 29, 2015
Due 10:00 AM, Monday, February 2, 2015

Homework 1: C review, Processes

These problems should be done on your own. We're not going to be grading them strictly (we'll mainly look at whether you attempted them). But they will be reinforcing knowledge and skills, so you should totally work through them carefully.

Problem 1:

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.

Problem 2:

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.

Problem 3:

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.

Problem 4:

Below is another snippet of C code:

int a[5];

a[0] = 0;
a[1] = 10; 
a[2] = 100;


a[3] = *a + 2;
a[4] = *(a + 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?

Handing in the homework

Use NYU Classes; there's an entry for this homework.

Last updated: Mon May 04 11:24:46 -0400 2015 [validate xhtml]