* select.c
* - Implements the select() system call (and supporting code)
*
- * TODO: Implment timeouts (via an alarm event?)
* TODO: Remove malloc for read/write queues
*/
#define DEBUG 0
{
LOG("Semaphore_Wait()");
// TODO: Actual timeout
- Threads_WaitEvents( THREAD_EVENT_VFS );
+ Threads_WaitEvents( THREAD_EVENT_VFS|THREAD_EVENT_SIGNAL );
}
else if( *Timeout > 0 )
{
LOG("Timeout %lli ms", *Timeout);
Time_ScheduleTimer( t, *Timeout );
// Wait for the timer or a VFS event
- Threads_WaitEvents( THREAD_EVENT_VFS|THREAD_EVENT_TIMER );
+ Threads_WaitEvents( THREAD_EVENT_VFS|THREAD_EVENT_TIMER|THREAD_EVENT_SIGNAL );
Time_FreeTimer(t);
}
if( !(TypeFlags & (1 << type)) ) continue;
VFS_int_Select_GetType(type, Node, &list, &flag, &wanted, &maxAllowed);
LOG("VFS_int_Select_RemThread()");
+ ASSERT(*list);
VFS_int_Select_RemThread(*list, thisthread);
ret = ret || *flag == wanted;
}
// Wait for things
if( !Timeout )
{
- LOG("Semaphore_Wait()");
+ LOG("Waiting for VFS/SIGNAL events (Plus 0x%x)", ExtraEvents);
// TODO: Actual timeout
- Threads_WaitEvents( THREAD_EVENT_VFS|ExtraEvents );
+ Threads_WaitEvents( THREAD_EVENT_VFS|THREAD_EVENT_SIGNAL|ExtraEvents );
}
else if( *Timeout > 0 )
{
Time_FreeTimer(t);
}
// Fill output (modify *Handles)
+ LOG("De-registering");
// - Also, de-register
ret = VFS_int_Select_Deregister(thisthread, MaxHandle, ReadHandles, 0, IsKernel);
ret += VFS_int_Select_Deregister(thisthread, MaxHandle, WriteHandles, 1, IsKernel);
// Mark a node as having data ready for reading
int VFS_MarkAvaliable(tVFS_Node *Node, BOOL IsDataAvaliable)
{
+ ASSERTR(Node, 1);
ENTER("pNode bIsDataAvaliable", Node, IsDataAvaliable);
Node->DataAvaliable = !!IsDataAvaliable;
if( Node->DataAvaliable )
// Mark a node as having a full buffer
int VFS_MarkFull(tVFS_Node *Node, BOOL IsBufferFull)
{
+ ASSERTR(Node, 1);
ENTER("pNode bIsBufferFull", Node, IsBufferFull);
Node->BufferFull = !!IsBufferFull;
if( !Node->BufferFull )
// Mark a node as errored
int VFS_MarkError(tVFS_Node *Node, BOOL IsErrorState)
{
+ ASSERTR(Node, 1);
ENTER("pNode bIsErrorState", Node, IsErrorState);
Node->ErrorOccurred = !!IsErrorState;
if( Node->ErrorOccurred )
void VFS_int_Select_RemThread(tVFS_SelectList *List, tThread *Thread)
{
- int i;
tVFS_SelectListEnt *block, *prev = NULL;
ENTER("pList pThread", List, Thread);
// Look for the thread
do
{
- for( i = 0; i < NUM_THREADS_PER_ALLOC; i ++ )
+ for( int i = 0; i < NUM_THREADS_PER_ALLOC; i ++ )
{
if( block->Threads[i] == Thread )
{