Lab 7

Here is your Lab 7.

Lab 7 is a graded exercise. You have two weeks to complete. Submit your solution to the IVLE workbin before Sunday, 30 October 2011, 10:00pm.

34 thoughts on “Lab 7

  1. Professor, I encountered some problems for the lab:

    1. I got permission denied for the /proc//maps command
    2. The stack.c runs perfectly after being compiled and doesn’t give expected output on gdb (in addition, the program exits after pressing n 3 times)

    Thank you

      • Hi Ivan and Prof,

        I was doing the lab7 in OS lab. I got the permission denied problem as well. How to go around it?

        Moreover, although the computer is connected to “Normal Port”, it is unable to launch firefox and worst, cant even wget the lab07-A000000X.txt (any files due to some unresolve host error).

        thank you.

  2. Professor,

    For 2(a), should we make “top” sort the processes in some other order instead (say, according to the VIRT column)? Otherwise the lab07-malloc process rarely appears in the list.

  3. Jonathan, you may try my method. I made my malloc.c program print the pid and issued top -pPID. That way, top only show that particular process’ information.

    By the way, the top man page used some terms that is not explained in lecture. I spent some time searching the net for it. I guess I shall just post my findings here for anyone who is also wondering what they mean.

    Swapping – This term is used interchangeably as paging. Contrary to our lecture, it does not mean writting entire process core image to the memory. In most OS nowadays such true swapping rarely occurs.

    swapped out – Occurs when the page is written to the disk.

    swapped in – Occurs when the page is returned to the memory.

    hope it helped.

    • Thanks for sharing.

      Yes, although in the textbook we differentiate between swapping and paging, modern systems use the term interchangeably. I will however, stick to the term swapping as meaning loading the whole process into contiguous region in memory, and paging as meaning dividing virtual/physical memory into pages/frames and loading pages on demand into frames, to be more precise and to differentiate these two very different schemes.

  4. For question 4, it says it’s worth 5 points, but it’s also worth 0 marks. Also, on the template for the answer sheet, it doesn’t provide a space for question 4. So does that mean we don’t actually have to answer that question? I’m confused.

  5. Why is that in lab07_malloc.c, there is an i*4 at the printf line? Why multiply by 4? Did I miss out something?

    From what I understand the program is doing, for every iteration in the while loop, 1 MB of memory is malloc’ed. So shouldn’t i*4 be just i instead?

    • Alamak. Another typo.

      I will alert the TA that if your answer is 4 times the correct one, it will be marked as correct.

  6. For some reason, I couldn’t get the code in question 3 running. When I’m trying to compile, it gives me the following error:

    /tmp/ccPOviYC.o: In function `main’:
    lab07-time1.c:(.text+0x13d): undefined reference to `clock_gettime’
    lab07-time1.c:(.text+0x179): undefined reference to `clock_gettime’
    collect2: ld returned 1 exit status

    So I found the header associated with clock_gettime (which is time.h) and included it in my code. Now I try to compile again and get the following:

    /usr/include/time.h:120:8: error: redefinition of ‘struct timespec’
    /usr/include/linux/time.h:9:8: note: originally defined here
    /usr/include/time.h:161:8: error: redefinition of ‘struct itimerspec’
    /usr/include/linux/time.h:42:8: note: originally defined here

    Am I doing something wrong?

    • Just like in Lab 3, you need to link with the real-time library.

      Try adding “-lrt” as an argument to gcc.

  7. Professor, for questions 2(a) and 2(d), do you mean that we should be pay attention to the %MEM column instead of the %CPU column?

    • Jonathan,

      Whatever relevant and significant difference(s) you can observe in the output.


  8. This is kinda unrelated. (i think!) but I guess I just wanna ask out of curiosity.

    Some people on online forums claim that to get the first parameter of the current function, we do ebp-4. Is that true? It seems that it doesn’t apply to my intel machine.

    is this related to how the stack grows? either upwards or downwards?

  9. For question 3(b), i will like to ask if we are supposed to write down the average time taken to modify the content of a memory location, or the total time taken for N (N * average time)?

    Thank you.

  10. specifically im refering to the problem where the OS lab cannot allow firefox use, wget or maps for process

    • The TAs reported that there are many issues with the lab machines today — possibly due to school-wide network failure.

      Am checking with the lab technician.

  11. Hi all,

    Do take note that the lab07-time*.c program prints the time in MICROseconds. Whereas for question 3b, the example uses MILLIseconds. Don’t get tricked. ;)

Comments are closed.