If any of the URLs is broken in the lab handout, please add “1112s1” to the URL.
For example, instead of
http://www.comp.nus.edu.sg/~cs2106/lab07-malloc.c
use
http://www.comp.nus.edu.sg/~cs2106/1112s1/lab07-malloc.c
If any of the URLs is broken in the lab handout, please add “1112s1” to the URL.
For example, instead of
http://www.comp.nus.edu.sg/~cs2106/lab07-malloc.c
use
http://www.comp.nus.edu.sg/~cs2106/1112s1/lab07-malloc.c
19 November 2011
By request, here are the exam questions for discussion online.
Bid to program new life forms with ‘operating system’ for cells.
http://edition.cnn.com/2011/11/18/tech/innovation/program-living-cells/index.html
“For each single application you have in mind, you have to start from scratch, and you have to start all of the design of the biological roots from scratch,” he said. “The analogy in the computer industry would be that each time you write a computer program you have to write the entire operating system.”
That’s why Krasnogor hopes his team will be able to create a line of cells running a generic “cellular operating system” that could be re-programmed with different applications.
All the best for the exam. It has been fun teaching CS2106 again this semester.
(If you haven’t go to bed, consider doing so soon. You will need a fresh mind to think tomorrow.)
The number of comments discussing the past year questions hit a record of 100 today. I thought it would be useful to summarize the confusing points from the discussion in a post here.
Q1
Q2.
Q3
Q4
Q8
Q10
Q11
Q12
Q15
If you are creating new threads, please start your discussion here.
The comments on the other post is getting too long and confusing.
Lab 8 has been graded. The grades and comments are available through IVLE gradebook.
As usual, please take a look and let me know if you see any unpleasant surprise.
Most of you did not setup the pipes properly. When I print out what you pipe/dup/close, things are pretty messy. Some create extra pipes, some do not close unused ends, some close everything, some dup the file descriptors in wrong order, etc.
We deduct marks according depending on how serious is your bug.
It’s very sad that despite multiple warnings, students still do not follow instructions, resulting in extra time needed to grade the labs, and delaying the release of marks for everyone. As promised in the lab sheet, 3 marks are deducted accordingly for these students *heart pain*
I would like to make a correction to a wrong fact I said in class.
Suppose we have a file P, which is a soft link to another file Q. During the lecture, I incorrectly said that the address inside i-node of P contains the i-node number of Q. This is WRONG. The i-node of P contains address of the data block of P on disk instead (just like normal file). To implement the link, in the data blocks on disk, we store a string that contains the path to Q.
Here is a video that re-explains this: http://goo.gl/3pbt3
What are the pros and cons of these two different approaches?
If we store the path to Q, then we need to take extra steps navigating through the file hierarchy to find the i-node of Q. Whereas if we store the i-node number of Q, we can access Q directly. On the other hand, if we store the path to Q, Q can be a file residing in a different partition.
But here is a deal breaker: what happen after Q is deleted? In both approaches, when we access P, we will encounter an error. But, if we store the i-node number of Q, this i-node number can be reused by another file!! So P can unintentionally linked to another file at a later time. This is not good.
Sorry for the confusion caused by this error.
We are in the middle of grading Lab 8. In the mean time, take a look at one possible solution below:
int main() { // code removed for brevity : : } else { // loop through each commands, setup pipes. int i; int fd[2*MAX_PIPE_LENGTH]; for (i = 0; i < num_of_cmds; i++) { // for k cmds, there should be k-1 pipes. // the ith cmd reads from fd[2i-2], write to fd[2i+1]. if (i < num_of_cmds - 1) { pipe(&fd[2*i]); } pid = fork(); int read_from = (i<<1)-2; int write_to = (i<<1)+1; switch (pid) { case -1: perror("fork"); exit(1); case 0: if (i != 0) { if (dup2(fd[read_from], STDIN_FILENO) == -1) perror("dup2"); close(fd[read_from+1]); } if (i != num_of_cmds-1) { if (dup2(fd[write_to], STDOUT_FILENO) == -1) perror("dup2"); close(fd[write_to-1]); } execvp(args[i][0], args[i]); perror(args[i][0]); close(fd[read_from]); close(fd[write_to]); exit(1); default: if (i > 0) { if (close(fd[2*i-2]) == -1) { perror("close"); } if (close(fd[2*i-1]) == -1) { perror("close"); } } break; } } for (i = 0; i < num_of_cmds; i++) waitpid(-1, NULL, 0); } free(command); } return 0; }
The grading for Lab 6 is done. As usual, please email me if the grade is not what you expected or you have any questions about the given remarks.
Disappointingly, many of you throw away precious points, just like that, by not following instructions on how to name files and the length of pages.
Many of you also did not explain the graphs, but merely describe what the graph looks like in words. Describing pictures is easy — given the graphs, anyone can describe what it looks like without know what is RR or MLFQ. The lab question specifically ask you to explain (i) and (ii). If you describe the graphs rather than explaining them, you would loose two points.
Here are the key points to mention: