// === GLOBALS ===
// === FUNCTIONS ===
-int VFS_SelectNode(tVFS_Node *Node, enum eVFS_SelectTypes Type, tTime *Timeout)
+int VFS_SelectNode(tVFS_Node *Node, enum eVFS_SelectTypes Type, tTime *Timeout, const char *Name)
{
tVFS_SelectThread *thread_info;
tVFS_SelectList **list;
}
thread_info = malloc(sizeof(tVFS_SelectThread));
- if(!thread_info) return -1;
+ if(!thread_info) LEAVE_RET('i', -1);
- Semaphore_Init(&thread_info->SleepHandle, 0, 0, "VFS_SelectNode()", "");
+ Semaphore_Init(&thread_info->SleepHandle, 0, 0, "VFS_SelectNode()", Name);
LOG("list=%p, flag=%p, wanted=%i, maxAllowed=%i", list, flag, wanted, maxAllowed);
thread_info = malloc(sizeof(tVFS_SelectThread));
if(!thread_info) return -1;
- Semaphore_Init(&thread_info->SleepHandle, 0, -1, "VFS_Select()", "");
+ ENTER("iMaxHandle pReadHandles pWriteHandles pErrHandles pTimeout bIsKernel",
+ MaxHandle, ReadHandles, WriteHandles, ErrHandles, Timeout, IsKernel);
+
+ Semaphore_Init(&thread_info->SleepHandle, 0, 0, "VFS_Select()", "");
- // Notes: The idea is to make sure we onlt enter wait (on the semaphore)
+ // Notes: The idea is to make sure we only enter wait (on the semaphore)
// if we are going to be woken up (either by an event at a later time,
// or by an event that happened while or before we were registering).
// Hence, register must happen _before_ we check the state flag
ret += VFS_int_Select_Register(thread_info, MaxHandle, WriteHandles, 1, IsKernel);
ret += VFS_int_Select_Register(thread_info, MaxHandle, ErrHandles, 2, IsKernel);
+ LOG("Register ret = %i", ret);
+
// If there were events waiting, de-register and return
if( ret )
{
ret += VFS_int_Select_Deregister(thread_info, MaxHandle, WriteHandles, 1, IsKernel);
ret += VFS_int_Select_Deregister(thread_info, MaxHandle, ErrHandles, 2, IsKernel);
free(thread_info);
+ LEAVE('i', ret);
return ret;
}
if( !Timeout || *Timeout > 0 )
{
ret = Semaphore_Wait(&thread_info->SleepHandle, 1);
+ // TODO: Do something with ret?
}
// Fill output (modify *Handles)
ret += VFS_int_Select_Deregister(thread_info, MaxHandle, WriteHandles, 1, IsKernel);
ret += VFS_int_Select_Deregister(thread_info, MaxHandle, ErrHandles, 2, IsKernel);
free(thread_info);
+ LEAVE('i', ret);
return ret;
}
if( !Handles ) return 0;
- ENTER("pThread iMaxHandle pHandles iType BIsKernel", Thread, MaxHandle, Handles, Type, IsKernel);
+ ENTER("pThread iMaxHandle pHandles iType iIsKernel", Thread, MaxHandle, Handles, Type, IsKernel);
for( i = 0; i < MaxHandle; i ++ )
{
// Is the descriptor set
if( !FD_ISSET(i, Handles) ) continue;
+ LOG("FD #%i", i);
handle = VFS_GetHandle( i | (IsKernel?VFS_KERNEL_FLAG:0) );
// Is the handle valid?
if( !Handles ) return 0;
- ENTER("pThread iMaxHandle pHandles iType BIsKernel", Thread, MaxHandle, Handles, Type, IsKernel);
+ ENTER("pThread iMaxHandle pHandles iType iIsKernel", Thread, MaxHandle, Handles, Type, IsKernel);
for( i = 0; i < MaxHandle; i ++ )
{
// Is the descriptor set
if( !FD_ISSET(i, Handles) ) continue;
+ LOG("FD #%i", i);
handle = VFS_GetHandle( i | (IsKernel?VFS_KERNEL_FLAG:0) );
// Is the handle valid?
int i;
tVFS_SelectListEnt *block;
+ if( !List ) return ;
+
ENTER("pList", List);
// Lock to avoid concurrency issues
{
for( i = 0; i < NUM_THREADS_PER_ALLOC; i ++ )
{
- LOG("block->Threads[i] = %p", block->Threads[i]);
if( block->Threads[i] )
{
+ LOG("block(%p)->Threads[%i] = %p", block, i, block->Threads[i]);
Semaphore_Signal( &block->Threads[i]->SleepHandle, 1 );
}
}