Daniel Ramsbrock
2005-09-28 01:19:05 UTC
Here is a list of project 2 items I'd like to have clarified, preferably
by a TA or Dr. Hicks. Most of them should be straightforward answers,
and I think the whole class will benefit from the answers:
1. SIGCHLD: Do we add code to the Exit() function in kthread.c to send
SIGCHLD to our parent? Obviously, we send SIGCHLD to the parent when
killing a child. Are there any other times when a SIGCHLD should be
generated?
2. Do we need to check the validity of the pointers being passed into
Sys_Signal and Sys_RegDeliver (i.e. should we run them through
Validate_User_Memory)?
3. When calling Complete_Handler from Sys_ReturnSignal, do we pass the
variable 'state' as the second parameter (esp)?
4. What is the purpose of the second parameter (esp) of Setup_Frame and
Complete_Handler? I don't use it in either one--should I be using it
somehow? I only use kthread->esp, which is the stack pointer of the
thread in question.
5. Whenever we call Copy_To_User, we don't have to check that enough
user memory is available, correct? As far as I can tell,
Validate_User_Memory, which gets called from Copy_To_User, takes care of
this automatically. Along those same lines, should we be checking the
return code of Copy_To/From_User in Setup_Frame and Complete_Handler to
make sure the stack was copied OK? If so, what action(s) should we take
on failure?--both return void, so we would have to modify that in order
to return an appropriate error code.
6. If any of the syscalls Sys_Signal, Sys_RegDeliver, and
Sys_ReturnSignal are called by a kernel thread (i.e.
g_currentThread->userContext == NULL), they should fail with EACCESS or
something like that, right?
7. On the other hand, Sys_Kill and Sys_WaitNoPID should work even if the
caller is a kernel thread, right?
8. Is it OK to reset the 'pending' flag for a signal at the end of
Setup_Frame (i.e. as soon as the EIP has been set to the proper handling
address)? This way, if the same signal is received again while it's
being handled, the handler would be called again.
9. Accessing user space: Many people have been talking about converting
all kinds of things between user and kernel address space. To me, it
seems like the only time this is necessary is when copying the
Interrupt_State struct from the kernel stack to the user stack (in
Setup_Frame) and back from the user stack to the kernel stack (in
Complete_Handler). I see no reason to convert the handler addresses back
and forth--even though the addresses are being passed to syscalls, the
handlers are being invoked from within a user process. When setting the
EIP of the user process (in Setup_Frame), this address would have to be
in user address space anyway since that's where the user process will
resume execution. In other words, my implementation works fine by
leaving the passed-in handler address alone, storing it in userContext,
and then copying that value to the Interrupt_State->eip field on the
kernel stack when Setup_Frame is called.
Sorry for all the questions--hopefully most of them are indeed easy
answers. Thanks,
Daniel
by a TA or Dr. Hicks. Most of them should be straightforward answers,
and I think the whole class will benefit from the answers:
1. SIGCHLD: Do we add code to the Exit() function in kthread.c to send
SIGCHLD to our parent? Obviously, we send SIGCHLD to the parent when
killing a child. Are there any other times when a SIGCHLD should be
generated?
2. Do we need to check the validity of the pointers being passed into
Sys_Signal and Sys_RegDeliver (i.e. should we run them through
Validate_User_Memory)?
3. When calling Complete_Handler from Sys_ReturnSignal, do we pass the
variable 'state' as the second parameter (esp)?
4. What is the purpose of the second parameter (esp) of Setup_Frame and
Complete_Handler? I don't use it in either one--should I be using it
somehow? I only use kthread->esp, which is the stack pointer of the
thread in question.
5. Whenever we call Copy_To_User, we don't have to check that enough
user memory is available, correct? As far as I can tell,
Validate_User_Memory, which gets called from Copy_To_User, takes care of
this automatically. Along those same lines, should we be checking the
return code of Copy_To/From_User in Setup_Frame and Complete_Handler to
make sure the stack was copied OK? If so, what action(s) should we take
on failure?--both return void, so we would have to modify that in order
to return an appropriate error code.
6. If any of the syscalls Sys_Signal, Sys_RegDeliver, and
Sys_ReturnSignal are called by a kernel thread (i.e.
g_currentThread->userContext == NULL), they should fail with EACCESS or
something like that, right?
7. On the other hand, Sys_Kill and Sys_WaitNoPID should work even if the
caller is a kernel thread, right?
8. Is it OK to reset the 'pending' flag for a signal at the end of
Setup_Frame (i.e. as soon as the EIP has been set to the proper handling
address)? This way, if the same signal is received again while it's
being handled, the handler would be called again.
9. Accessing user space: Many people have been talking about converting
all kinds of things between user and kernel address space. To me, it
seems like the only time this is necessary is when copying the
Interrupt_State struct from the kernel stack to the user stack (in
Setup_Frame) and back from the user stack to the kernel stack (in
Complete_Handler). I see no reason to convert the handler addresses back
and forth--even though the addresses are being passed to syscalls, the
handlers are being invoked from within a user process. When setting the
EIP of the user process (in Setup_Frame), this address would have to be
in user address space anyway since that's where the user process will
resume execution. In other words, my implementation works fine by
leaving the passed-in handler address alone, storing it in userContext,
and then copying that value to the Interrupt_State->eip field on the
kernel stack when Setup_Frame is called.
Sorry for all the questions--hopefully most of them are indeed easy
answers. Thanks,
Daniel