CS 3733 Operating Systems, Fall 2008 Assignment 4 Comments
Comments from the progress report:
- Please use the macros when waiting for children.
- When you allocate space for a string, remember the null character.
- compile should return only 0 or 1
- execl needs a final NULL parameter.
Comments added after grading the full assignment:
- Question 1 was about testing you program, not about how you wrote the
program. The problem is that you want to test every path through the
program, but some paths are very unlikely, such as a malloc failure.
- Question 3:
Parts 1 and 2 have 4 processes, a parent and 3 children.
Part 3 has 5 processes, an extra child to do the final compile.
Part 4 has 8 processes. Each call to compile generate 2 processes,
for a total of 6. Add 2 more for the main and the file executable
creation.
- It is not good style to put calls to important functions in a print, as in
fprintf(stderr,"Compile returned %d\n",compile(...));
Someone might try to clean this up by commenting out the print statement.
- Make sure you allocate enough space. What is wrong with:
tmp = malloc(strlen(argv[i]);
strcpy(tmp,atgv[i]);
strcat(tmp,".o");
- It makes a difference where you malloc. What is the difference between:
tmp = malloc(xxx);
child = fork();
and
child = fork();
if (child == 0)
tmp = malloc(xxx);
- On the extra credit: Two people tried part 5 and one did 6 and 7 also.
- For Part 7, you can suppress output by redirecting the output
to /dev/null before calling exec.