Subject: Test message + Assn 1 (This message is being sent to all CPSC 422/622 students) This message is being sent to verify that the mailing list is complete. If you receive it and are in the class, do nothing!! If you receive it and have dropped the class let me know and I'll drop you from the list. If you don't receive it you should contact me ;-). ------------------ The assignment 1 specification is now available. See assn1.s03 mw Subject: Assn 1 directories (This message is being sent to all CPSC 422/622 students) The directories into which assn 1 is to be submitted have been created. <<>>> Subject: Assn 1 submissions (This message is being sent to all CPSC 422/622 students) This procedure for submitting your assignments is <<>> the "handin" procedure used in some undergraduate courses. It has no relation to "handin", and anything you try to recollect about using "handin" will only MESS YOU UP. You must use the unix copy command "cp" to copy the files from your directory to the target directory AFTER logging in to workstation "jmw" Subject: Assn 1 submissions (This message is being sent to all CPSC 422/622 students) I have received some additional queries of the type: 1 - May I submit a *ball (tar, zip, bz) 2 - May I submit a script named make rather than a makefile 3 - May I name my executable dkjreiouls##Riewldiol^!@(e.out instead of a.out 4 - May I submit a Window$/Linux equivalent instead of the sun version 5 - May I write my output to a file named assn1.out instead of the standard output The answer to all of the above is "NO". Other questions have related to evaluation criteria 1 - Will I be penalized if my program has no comments at all! The answer is YES! I recommend reading "eval.txt" as was recommended in assn1.s03. Comments compatible with the sample programs are safe. In general I HIGHLY encourage paying detailed attention to specification and submission requirements. 2 - How long should a reasonably well written program be? The program I hacked together last week with no particular effort to minimize lines of code contains 44 semicolons. /home/westall/acad/cs422/examples/procfs ==> grep ";" tabproc.c | wc -l 44 However, anything less than 60 ;'s is unlikely to incur any ugly implementation penalty pts. 3 - Does it matter if the order in which processes that have consumed 0 CPU time differs from your order. NO Subject: Assn 2 specification (This message is being sent to all CPSC 422/622 students) Is now available. See assn2.s03 Subject: Assn 2 specification (This message is being sent to all CPSC 422/622 students) There are (at least) two possible approaches to assn2 The one that seemed easist to me and required < 20 ";"s was to have the parent process create all the children. Another reasonable approach that was suggested by a student today is to have the main process create the first child and then have each child create both its successor and the pipe that connects them and then (presumably) have the child process call the child generator / copier function recursively. As long as the NO GLOBALS constraint is not violated this approach is OK (but it seems to make it more difficult to me avoid having to special-case the first and last child). Subject: Assn 2 (This message is being sent to all CPSC 422/622 students) There is an executable version of the program in the class directory. An example of how to run it is: pipeline 5 < all.t1 It doesn't check for invalid number of processes and so BE careful that 2 <= n < 32 when running it. A good way to test your own program is to run: a.out 14 < some_big_file.in > some_big_file.out diff some_big_file.in some_big_file.out You will need to create the file named some_big_file.in first. If the diff command generates any output that is a bad sign!!! After testing a broken program be sure to run ps -fed | grep a.out or ps -aux | grep a.out and then manually kill -9 pid where pid is the pid number of your old a.outs. Subject: Visit of Executive Director of Gnome Foundation Tim Ney, the executive director of the Gnome Foundation will make a presentation on aspects of the free software (open source) movement at 7:00 pm tonight in Jordan G-33. Check it out if you get a chance. mw Subject: Assn1 grades (This message is being sent to all CPSC 422/622 students) I will be sending these out shortly. If you worked with a partner only the person in whose directory the assignment was turned in will get a report. So please forward to your partner. ------------------ One thing that I did not penalize in this assignment but may well do in future assignments is extra long lines of code.. For readability they should not exceed 70 characters. Instead of: procs[count].utime = ( usage.pr_utime.tv_sec ) + ( usage.pr_utime.tv_nsec * 1E-9 ); use procs[count].utime = ( usage.pr_utime.tv_sec ) + ( usage.pr_utime.tv_nsec * 1E-9 ); for improved readability. ------------------ Because of the lateness of the hour, assn 2 will not be due until Friday at 23:59. Subject: Out of town (This message is being sent to all CPSC 422/622 students) I forgot to announce that I will be out of town this afternoon and tomorrow a.m. Should return by 2:30 or so tomorrow. mw Subject: Assn 3 available (This message is being sent to all CPSC 422/622 students) Assignment 3 is available in assn3.s03. Please try to look over it before class on Friday. I will provide a diagram of the intended operation then and will be happy to try to answer any questions. mw Subject: Assn 3 info (This message is being sent to all CPSC 422/622 students) When building ANY pthread application it is necessary to link with the pthread library. gcc foo.c -lpthread The character before pthread is the letter l NOT the digit 1 If you don't do that, no errors or warnings will ensue but ALL pthread calls turn in to no-ops!! Subject: Test 1 info (This message is being sent to all CPSC 422/622 students) The test key is available in test1key.s03 Tests have been graded and will be returned as soon as we can get the grades recorded. Subject: Test 1 correction (This message is being sent to all CPSC 422/622 students) It turns out that BOTH (b) and (c) are correct answers to number 27. Entry code (correct) Exit code (broken) [1] wait(rmutex); [1] wait(rmutex); [2] rcount++; [2] rcount--; [3] if (rcount == 1) [3] signal(rmutex); [4] wait(wsem); [4] if (rcount == 0) [5] signal(rmutex); [5] signal(wsem); The deadlock occurs as follows: - Last reader decrements rcount to 0 and is pre-empted after line [3] in the exit code. - A new reader arrives sets rcount back to 1 and thus waits on wsem (because the exiting reader hasn't signaled it yet). - When the Last reader is redispatched it finds rcount == 1 and thus doesn't signal wsem. ==> There is now a deadlock because wsem will NEVER be signalled. The unsafe situation occurs as follows: - Two readers are reading - The next to the last reader exits, decrements rcount to 1, and is preempted between lines [3] and [4]. - The last reader decrements rcount to 0 and signals wsem - The next to the last reader resumes, finds rcount == 0 and also signals wsem. ==> Now wsem has the value 2 and so an arriving writer and reader are able to write and read concurrently. Thus, if you answered (b) and lost three pts please bring your paper back to class and we'll be happy to restore you points. Thanks to Mr. McPherson for identifying the unsafe situation. mw Subject: Assn 3 (This message is being sent to all CPSC 422/622 students) Counting semaphores are not needed and <> in the present assignment. Work directly with pthread condition variables and mutexes instead. I will also have to be out of the office this morninng I should be back around 2:00 this aft Subject: Assn 3 (This message is being sent to all CPSC 422/622 students) Interleaving of blocks in the buffer will normally be quite coarse grained. In fact it will be so coarse that unless you use relatively large input files you may not see it at all. Theoretically, at least, if each thread calls sched_yield() after it adds a block to the buffer, it should radically alter this behavior (and make for more thorough testing). I haven't tried this myself and so I can't vouch that Sun didn't decided to save a few $0.01s by making sched_yield() a no-op. Subject: Assn 3 (This message is being sent to all CPSC 422/622 students) Turn in directories are ready. mw Subject: Assn 3 specification clarification (This message is being sent to all CPSC 422/622 students) It is expected that the Consumer WILL consumed data in FCFS order. That is bytes will be removed from the buffer in precisely the order in which they were placed into the buffer... This is the easiest and sanest solution! Subject: Proper holding of mutexes used with condition variables (This message is being sent to all CPSC 422/622 students) (Sorry about that last message -- made a little typo in sending here is what I was trying to send) There seem to be a number of programs suffering from an affliction relating to improper use of mutexes. It is common for entity Y to use a CV to wait until global variable "foo" attains some value. Entity X then adjusts "foo" and broadcasts the CV waited upon by entity Y. For this process to safely avoid potentially fatal race conditions, it is MANDATORY that entity X hold the mutex <> while it updates "foo" and broadcasts the CV. example: Entity C: (for example, the consumer) p_m_l(&mtx); while (foo < bar) p_c_w(&cv, &mtx) p_m_u(&mtx); Entity P: (the producer) p_m_l(&mtx); foo += something; p_m_b(&cv); p_m_u(&mtx); Subject: Assn 4 (This message is being sent to all CPSC 422/622 students) Apparently the file assn4.s03 became re-protected during all of the filesystem afflictions of the last few days. I have unprotected again. Hopefully it will stay that way this time. mw Subject: Assn 4 (This message is being sent to all CPSC 422/622 students) There was some incorrect info near the bottom of the assignment statement that indicated any approach to the memory management system was OK. That is not the case. Only the Buddy system is OK. mw Subject: Assn 4 - Clarification rgdng out of memory (This message is being sent to all CPSC 422/622 students) A student with a misconception makes the following statement prior to asking a question: > In the case our big gob of memory getting most of the way filled up and > then a new proccess comes in and there is not enough free memory > available for that process it must then wait on space..... The misconception is that some manner of waiting is desired when memory is not available. This is NOT the case. When a request cannot be satisified, NULL (0) should be returned as stated in the comment before the xm_alloc() header. /* This entry is used to allocate a sub-gob from */ /* the big gob.. It should return 0 if the amt */ /* requested is not available. It should return */ /* the address of the allocated memory if it is. */ This behavior is consistent with the "real" malloc as shown in the following extract from the man page. RETURN VALUE For calloc() and malloc(), the value returned is a pointer to the allo- cated memory, which is suitably aligned for any kind of variable, or NULL if the request fails. Subject: More confusion on assn4 (This message is being sent to all CPSC 422/622 students) > The prototype's of the function's given in the hand-out and in > buddy-skeleton.c files are different. Can you tell us which we > should use You MUST use the interfaces defined in assn4.s03 buddy-skeleton.c was just something I found at some other university that I thought might help give some idea of the elements of the implementation. If you find it not useful or confusing just discard it. <> of buddy-skeleton.c is required in your submission. Subject: Use of web resources (This message is being sent to all CPSC 422/622 students) A student asks .. > I don't want to mess around with academic dishonesty > so how much of stuff I find on the web can I use... Since the buddy system is a rather standard algorithm you may be able to find pretty much complete solutions on the web. If you decide to turn in one of these I will NOT consider it Academic Dishonesty AS LONG AS YOU SPECIFICALLY CITE THE URL on which your submission is based. However, I WILL base about 50% of your grade on your contribution to the code. So if your contribution is 0% your grade will be around 50. Remember that I know how to use google too! So submitting a solution that is NOT your own without proper citation will likeyly result in a grade of zero and a writeup for academic dishonesty!! Subject: Assn 4 - Clarification rgdng global vars (This message is being sent to all CPSC 422/622 students) A student asks: > Can I assume severe penalties for global variables with this > assignment? Sensible use of global variables is NECESSARY in this assignment... Things such as the base address of the big-gob free list(s), and allocated list headers pretty much have to be global. Things like loop indices should however NOT be global. Subject: Assn 4 refusals.. (This message is being sent to all CPSC 422/622 students) > When I compile with just the DEBUG defined, and not THE_REAL_DEAL, it seems > to work fine, but when I incorporate multiple threads, I get a large number > of refusals on the requests. I am not sure what this means, or how I would Refusals are not necessarily an indication of an error. As seen in the comment below each request can be for as much as 1/4 of the available memory and so with 8 threads running you can run out. /* Grab a random size between 1 byte and gobsize / 4 */ size = gobsize * 1.0 * random() / 0x7fffffff; size /= 4; if (size == 0) size = 1; If you change size /= 4 to size /= 20 refusals should go away. If they don't then you probably do have a problem. Subject: Assn 4 due date.. (This message is being sent to all CPSC 422/622 students) It now appears that I will not make the return deadline of 11 April. Thus the due date is now April 14. I will get assn 3 graded over the weekend. ------------------------------- Remember that there is a test on April 16. Subject: Assn 3 grades (This message is being sent to all CPSC 422/622 students) I will be sending these out shortly. The test data is in the class directory. thread0/1s. in = small test thread0/1l. in = large test As usual if you think I misunderstood how your program worked or failed to work I will be glad to run a demo for you if you come by my office. Subject: Assn 4 and the "pow" function (This message is being sent to all CPSC 422/622 students) Several students have asked "what does the << operator do" and "how do I get the pow() function to do ..... " These two problems are tightly coupled. The pow() function requires double precision operands, is designed for floating point environments, and is a TRULY poor way to compute a power of two. The correct way to compute 2 to the nth power is to use the << (shift left) operation as follows: answer = (1 << n); This is always hardware supported and very fast. Subject: Assn 4 and mutexes (This message is being sent to all CPSC 422/622 students) Some folks seem to be thinking that the issue of mutex in the assignment is more difficult than it is. Here is the bottom line: 1 - You need one mutex 2 - It should be locked immediately after entry to xm_alloc() or xm_free() 3 - It should be unlocked immediately before return from xm_alloc() or xm_free. and thats all there is to it. ---------------- Subject: Makefiles and logarithms (This message is being sent to all CPSC 422/622 students) You don't need to submit a makefile for this assignment. --------------------- The use of the log() and log10() function (like the pow()) and exp() functions is unnecessary and strongly discouraged. Their use is less effecient than integer based approaches and many OS kernels FLATLY FORBID the use of floating point within systems calls (I know this is not a "real" system call, but avoiding unnecessary floating point is a "real" good habit to get into.) --------------------- Possible exam question: Why would an OS kernel writer forbid the use of floating point in the kernel? Subject: test2 answer key (This message is being sent to all CPSC 422/622 students) See test2key.s03 Subject: Grades I have finished grading the last assignment and I have asked Ms. Spicer to send out a complete copy of our view of your grades. If you have submitted late assignments that are not reported or think that we lost any of your assignment grades please let me know (I am aware of some of these but it would be good if EVERYONE in this category could speak up). If you think we have quiz or test grades wrong please take the quiz or test to Ms. Spicer. (Remember that some quizzes were incorrectly labeled). I have put all the quizzes in all.s03 so please check before going to see her. Final grades will not be available until Tuesday a.m.