Lab 6

Here is your Lab 6.

Lab 6 is a graded exercise. Submit your solution to the IVLE workbin before Friday, 14 October 2011, 10:00pm. It is longer than the past labs, so please plan your time properly.

66 thoughts on “Lab 6

      • I’ve downloaded the tarball again, but the compare target is still missing. Also, the printing of the averages is missing from job_manager_report_stats in job.c. (As a sidenote, job_generator does not return 0 at the end of main.)

        It seems that we do not have rights to install packages on the machines in the OS Lab. It would be nice to have ctags installed (I had to compile from source).

  1. Professor, I want to clarify something.

    Suppose I have a job at queue with priority 1
    The job is blocked, and have running time left 0
    The job will be placed into queue with priority zero

    My question is, is the running time left updated to the time quantum of priority 0 or priority 1?

    Thank you

    • If the process is blocked for IO, and:
      – … there is no change in priority, then the next time it is scheduled to run, it will run with whatever is left of the time quantum before it was blocked.
      – … there is a change in priority, then the next time it is scheduled to run, it will run with a full time quantum correspond to the new priority,

      • Suppose we have a job running at the highest priority and it blocks for IO. When it becomes ready to run again, it should be promoted to a higher priority but is not because there are no higher priorities to join. Hence, it rejoins the same queue. In this case, should its time quantum be reset or will it continue using what is was allocated?

        • Hi,

          For the issue regarding whether we should reset or not the time quantum of a blocked process that’s already in the highest priority level, every TA is saying something different. Hong Dai Thanh specified above that the process will run with whatever is left of the time quantum before it was blocked whereas ZHOU HUFENG is saying that we should reset the time quantum (assign max_time_quantum to it). Professor, can you please clarify this ?

          Thank you


          • In the grand scheme of things, it does not have much significant effect on the relative performance of MLFQ vs. RR. So either is fine.

  2. Hi Prof,

    Refer to job.c , line 80
    Shouldnt the order of the params to fprintf for the format string be:

    j, job_id, job->burst_length[j]

    instead of:

    job_id, j, job->burst_length[j]


  3. Dear Prof, in this week we have some other mid-term exams and project to submit, if its possible, please consider postponing the submition of lab-6 to next week?

    • Lab 6 is due next week on Friday. So this Friday we have our midterm and exactly 1 week from the midterm is the due date of our lab.

  4. May I ask if the Makefile still has some problems? I have problems running ‘make compare’. :/

      • The error I’ve gotten was this:

        for i in 10 20 30 40 50 60 70 80 90; \
        ./job_generator $i $((100-$i)) 1 > $i.txt; \
        ./sched $i.txt rr > $i.rr.out; \
        ./sched $i.txt mlfq > $i.mlfq.out; \
        sh: syntax error at line 3: `(‘ unexpected
        *** Error code 2
        make: Fatal error: Command failed for target `compare’

        • I see.. it looks like make is not running bash as I expected it to.

          If you encounter such error, please add the following line to the top of the Makefile


          It should work.

          • I have similar problem running ‘make compare’. I tried putting the additional line to the top of the Makefile, but similar error stream still obtained, just each line starting with /bin/bash instead of /bin/sh

            The error I got was:

            for i in 10 20 30 40 50 60 70 80 90; \
            ./job_generator $i $((100-$i)) 1 > $i.txt; \
            ./sched $i.txt rr > $i.rr.out; \
            ./sched $i.txt mlfq > $i.mlfq.out;\
            /bin/sh: line 1: 14950 Segmentation fault (core dumped) ./sched $i.txt mlfq > $i.mlfq.out
            /bin/sh: line 1: 14955 Segmentation fault (core dumped) ./sched $i.txt mlfq > $i.mlfq.out
            /bin/sh: line 1: 14959 Segmentation fault (core dumped) ./sched $i.txt mlfq > $i.mlfq.out
            /bin/sh: line 1: 14963 Segmentation fault (core dumped) ./sched $i.txt mlfq > $i.mlfq.out
            /bin/sh: line 1: 14967 Segmentation fault (core dumped) ./sched $i.txt mlfq > $i.mlfq.out
            /bin/sh: line 1: 14971 Segmentation fault (core dumped) ./sched $i.txt mlfq > $i.mlfq.out
            /bin/sh: line 1: 14975 Segmentation fault (core dumped) ./sched $i.txt mlfq > $i.mlfq.out
            /bin/sh: line 1: 14979 Segmentation fault (core dumped) ./sched $i.txt mlfq > $i.mlfq.out
            /bin/sh: line 1: 14983 Segmentation fault (core dumped) ./sched $i.txt mlfq > $i.mlfq.out
            make: *** [compare] Error 139

            Or perhaps it is something wrong with my mlfq implementation?

            • Yes. There is something wrong with your mlfq. Check through your code [Hint: priority try to decrease, if it is -1, can it still decrease?]

              • Hmm, I already put that constraint. Also do some debugging using printf. My mlfq seems to work with other jobs created with job_generator as well

  5. Hi, I wish to clarify the below part.
    * Called when a job becomes ready to run. Since the job blocks for I/O, the job priority becomes higher (smaller numerical value). The job joins the queue at its new priority.

    Say if the job that is ready to run, its current priority is level 3. Does it mean that when the ready job function is called, the priority level changes to level 2 (the next higher priority) or does it change to level 0 (the highest priority)?

  6. Hi, when i called make. The following warning appears and nothing printout for mlfq.

    May i know is the warning related to the printing of result and that is why i cant see any printout? How can i solve the clock skewing problem? I have tried using touch. But still not working.

    make: Warning: File `sched’ has modification time 36 s in the future
    ./sched JOBS rr
    0 5 0.00 14
    1 6 1.00 12
    AVG 5.50 0.50 13.00
    ./sched JOBS mlfq
    make: warning: Clock skew detected. Your build may be incomplete.

    • Seems like there is a clock synchronization problem between the lab machine and the network server. It is harmless in you case above, but it might cause a problem if you changed the C file and it does not get re-compiled as it should.

      I will let Mr. Chan, the lab tech knows about this issue.

      As for no output from MLFQ, it is expected since the skeleton code does not do anything useful for MLFQ.

      • I have the same problem (no output for MLFQ) even after implementing my code for MLFQ. Is it due to any error in my code?

        • This is a long shot, but did you run the correct executable? Double check the creation time of mlfq.

  7. Hi prof, will we get the same result for mlfq avg output after make compare? Cos I’ve checked with my friends but we do have some slight differences in the timing.


    • Hi Chee How, if your input is the same and output is slightly different, it is possible that your implementation is slightly different.

      Sorry, the above sentence does not say much. Perhaps you can compare your implementation to see what is different?

  8. Hi, when I called make compare. I will get this bus error. Does anyone know what is resulting my error? Thanks in advance! I’ve added the line SHELL=/bin/bash on top of Makefile.

    for i in 10 20 30 40 50 60 70 80 90; \
    ./job_generator $i $((100-$i)) 1 > $i.txt; \
    ./sched $i.txt rr > $i.rr.out; \
    ./sched $i.txt mlfq > $i.mlfq.out;\
    bash: line 1: 8351 Bus Error (core dumped) ./sched $i.txt mlfq >$i.mlfq.out
    *** Error code 138

  9. BTW, make compare is the command for the second part of the assignment.

    You should not run make compare to compare the performance of RR and MLFQ until you implemented the first part of the assignment (MLFQ) correctly.

    • I see. I did get the first part of the assignment correctly if you meant by getting the same output as shown. When I tried to compare the two results, I will get the bus error. Okay, I will try using gdb to debug.

      • I only gave you one test case. When you develop software, never be satisfied with passing one test case, especially a simple one! You should generate more test cases either manually or use the job_generator code given.

  10. my laptop only has office 2003… I don’t think I can save a doc as pdf with it
    why can’t we just submit doc?

    now I have to go to a different lab to get the pdf done, then come back to our lab in the basement to tar it and submit…

  11. Hi, I have problem running make compare. I keep obtaining the following error:

    *** Error code 100
    make: Fatal error: Command failed for target ‘compare’

    May I know what is the error? And how could I possibly solve it? Or is it my code that is causing the error? Thanks!

  12. If you encounter such error, please add the following line to the top of the Makefile


    Btw, this issue has been already addressed. If you go through the comments, you’ll notice that the professor has answered.

  13. I place the code of SHELL=/bin/bash at top of Makefile already, then I get that error when I run make compare

  14. Hi prof,

    May i know does it matter whether we reset the time_left for a job in the mlfq_block_job function?

    My idea is that, when a job is blocked, it changes from running state to blocked state. whether or not we reset the time_left at this state, this time_left will be updated again when the job is moved to a higher priority queue once the IO is served.

    So, am i right to say that it does not matter?

      • Reset and not reset the time_left in mlfq_ready method will change the output slightly.

        I was wondering will a process time_left be reset if it is block for I/O but the priority does not change (eg. priority level reach the highest level).

  15. Hi Prof,

    For mlfq_block_job(), if the time_left is 0, which means that it should be pre-empted, should we bring down the priority in addition to reset the time_left?

    Tan Ping Yang

    • If a job blocks for I/O when time_left is 0, you can treat it either as a block or a preemption.

  16. I got this problems:
    /bin/sh: line 2: ./job_generator: No such file or directory
    /bin/sh: line 3: ./sched: No such file or directory
    /bin/sh: line 4: ./sched: No such file or directory

  17. After examine a number of of the weblog posts on your

    web site now, and I really like your method of
    blogging. I

    bookmarked it to my bookmark website record and might be checking back soon.
    Pls check out my web page as properly and let me know what you think.

  18. There are certainly plenty of particulars like that to take into consideration.
    That is a nice point to bring up. I supply the thoughts above as

    normal inspiration however clearly there are questions just like the one

    bring up the place crucial factor

    might be working in trustworthy good faith. I

    don?t know if greatest practices have emerged around things like
    that, however

    I’m certain that your job is clearly recognized as a good game. Each girls and boys really feel the influence of just a second’s

    pleasure, for the rest of their lives.

  19. Attractive section of content. I just stumbled upon your weblog and in accession

    capital to assert that I get in fact enjoyed account your blog posts.

    Anyway I will

    be subscribing to your feeds and even I achievement you
    access consistently quickly.

  20. I’m really enjoying the design and layout of your site. It’s a very easy on the eyes which
    makes it

    much more enjoyable for me to come here and visit more often.
    Did you hire out a designer to create

    your theme? Outstanding work!

  21. hello!,I like your writing very a lot! share we

    keep in touch extra about your post

    on AOL? I require an expert in this area to resolve my

    problem. May be that’s you! Taking a look forward to

    look you.

  22. Hey there! I know this is kinda off topic

    but I was wondering if you knew where I could get a captcha plugin for my comment form?
    I’m using the same

    blog platform as yours and I’m having trouble finding one?
    Thanks a lot!

  23. Nice post. I used to be checking constantly this weblog and

    impressed! Extremely useful information particularly the

    final phase :) I maintain such

    info a lot. I used to be looking for this certain information

    for a very long time. Thanks and good luck.

Comments are closed.