[114] in 6.033-lab
Re: Lab 1 Questions, typos
daemon@ATHENA.MIT.EDU (Kevin Fu)
Sat Feb 20 12:48:53 1999
To: Matt Deeds <mdeeds@MIT.EDU>
Cc: 6.033-lab@MIT.EDU
In-Reply-To: Your message of Sat, 20 Feb 1999 11:07:52 -0500.
<199902201607.LAA17616@w20-575-8>
Date: Sat, 20 Feb 1999 12:48:44 EST
From: Kevin Fu <fubob@MIT.EDU>
Hi,
I'll CC the other lab students since you ask some good questions.
>Do the callback functions need to be called if cb_check is not called?
Nope. cb_check() is the only function that acts on the callbacks.
>Also, should cb_add get stuck if there are no available read/write
>descriptors and cb_check is being run via some other thread?
There is only one thread in this project. And cb_add wouldn't get
stuck since it can only take existing file descriptors. It does not
create new descriptors.
On a side note: before you call accept() in any function, you should
check that the number of file descriptors is fewer than FD_MAX.
Remember that stdout, stdin, and stderr count each use a file
descriptor.
>Why doesn't cb_check have the same restriction on cb_free as it
>does on cb_add?
>Or is that another typeo in the specs?
>i.e. in the cb_check specification
>"... before cb_add returns" should be "... before cb_check returns"
You are right; this is a typoe. It should say "before cb_check
returns"
>If file descriptor n is ready for both input and output, and no
>other descriptors are ready, does select return 1 or 2?
>The info in the handout is not clear. Is there a manpage for it?
>I am getting something else from 'man select'
select() will return the total number of bits set in the bit masks.
If you are selecting only file desc n for both reading and writing,
and both reading and writing become ready, then select will return 2.
Because there are multiple names called "select," you need to find the
right section in the man pages. Try typing "man -k select". Pages 1
and 2 of handout 2 (Tools of the Trade) describe how to search the man
pages. Man pages and sections vary by operating system. On a Solaris
box, I type:
man -s 3c select
whereas in Redhat Linux I type:
man 2 select
--------
Kevin E. Fu (fubob@mit.edu)
PGP key: finger fubob@monk.mit.edu