git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Modules/UDI - (minor) tiny fiddle to udic planning
[tpg/acess2.git]
/
KernelLand
/
Kernel
/
vfs
/
select.c
diff --git
a/KernelLand/Kernel/vfs/select.c
b/KernelLand/Kernel/vfs/select.c
index
b52414f
..
a18b91c
100644
(file)
--- a/
KernelLand/Kernel/vfs/select.c
+++ b/
KernelLand/Kernel/vfs/select.c
@@
-5,7
+5,6
@@
* select.c
* - Implements the select() system call (and supporting code)
*
* 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
* TODO: Remove malloc for read/write queues
*/
#define DEBUG 0
@@
-56,13
+55,14
@@
void VFS_int_Select_SignalAll(tVFS_SelectList *List);
// === FUNCTIONS ===
int VFS_SelectNode(tVFS_Node *Node, int TypeFlags, tTime *Timeout, const char *Name)
{
// === FUNCTIONS ===
int VFS_SelectNode(tVFS_Node *Node, int TypeFlags, tTime *Timeout, const char *Name)
{
- tThread *thisthread = Proc_GetCurThread();
- int ret
, type
;
+ tThread *
const
thisthread = Proc_GetCurThread();
+ int ret;
ENTER("pNode iTypeFlags pTimeout sName", Node, TypeFlags, Timeout, Name);
// Initialise
ENTER("pNode iTypeFlags pTimeout sName", Node, TypeFlags, Timeout, Name);
// Initialise
- for( type = 0; type < 3; type ++ )
+ ret = 0;
+ for( int type = 0; type < 3; type ++ )
{
tVFS_SelectList **list;
int *flag, wanted, maxAllowed;
{
tVFS_SelectList **list;
int *flag, wanted, maxAllowed;
@@
-78,41
+78,42
@@
int VFS_SelectNode(tVFS_Node *Node, int TypeFlags, tTime *Timeout, const char *N
VFS_int_Select_AddThread(*list, thisthread, maxAllowed);
if( *flag == wanted )
{
VFS_int_Select_AddThread(*list, thisthread, maxAllowed);
if( *flag == wanted )
{
- VFS_int_Select_RemThread(*list, thisthread);
- LEAVE('i', 1);
- return 1;
+ ret |= (1 << type);
}
}
// Wait for things
}
}
// Wait for things
- if( !Timeout )
+ if( ret )
+ {
+ // Skip wait, conditions already met
+ LOG("ret = %i, skipping wait", ret);
+ }
+ else if( !Timeout )
{
LOG("Semaphore_Wait()");
{
LOG("Semaphore_Wait()");
- // TODO: Actual timeout
- Threads_WaitEvents( THREAD_EVENT_VFS );
+ Threads_WaitEvents( THREAD_EVENT_VFS|THREAD_EVENT_SIGNAL );
}
else if( *Timeout > 0 )
{
tTimer *t = Time_AllocateTimer(NULL, NULL);
// Clear timer event
Threads_ClearEvent( THREAD_EVENT_TIMER );
}
else if( *Timeout > 0 )
{
tTimer *t = Time_AllocateTimer(NULL, NULL);
// Clear timer event
Threads_ClearEvent( THREAD_EVENT_TIMER );
- // TODO: Convert *Timeout?
LOG("Timeout %lli ms", *Timeout);
Time_ScheduleTimer( t, *Timeout );
// Wait for the timer or a VFS event
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);
}
// Get return value
ret = 0;
Time_FreeTimer(t);
}
// Get return value
ret = 0;
- for( type = 0; type < 3; type ++ )
+ for(
int
type = 0; type < 3; type ++ )
{
tVFS_SelectList **list;
int *flag, wanted, maxAllowed;
if( !(TypeFlags & (1 << type)) ) continue;
VFS_int_Select_GetType(type, Node, &list, &flag, &wanted, &maxAllowed);
{
tVFS_SelectList **list;
int *flag, wanted, maxAllowed;
if( !(TypeFlags & (1 << type)) ) continue;
VFS_int_Select_GetType(type, Node, &list, &flag, &wanted, &maxAllowed);
- LOG("VFS_int_Select_RemThread()
"
);
+ LOG("VFS_int_Select_RemThread()
for %i", type
);
ASSERT(*list);
VFS_int_Select_RemThread(*list, thisthread);
ret = ret || *flag == wanted;
ASSERT(*list);
VFS_int_Select_RemThread(*list, thisthread);
ret = ret || *flag == wanted;
@@
-164,9
+165,9
@@
int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set
// Wait for things
if( !Timeout )
{
// Wait for things
if( !Timeout )
{
- LOG("
Semaphore_Wait()"
);
+ LOG("
Waiting for VFS/SIGNAL events (Plus 0x%x)", ExtraEvents
);
// TODO: Actual timeout
// TODO: Actual timeout
- Threads_WaitEvents( THREAD_EVENT_VFS|ExtraEvents );
+ Threads_WaitEvents( THREAD_EVENT_VFS|
THREAD_EVENT_SIGNAL|
ExtraEvents );
}
else if( *Timeout > 0 )
{
}
else if( *Timeout > 0 )
{
@@
-181,6
+182,7
@@
int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set
Time_FreeTimer(t);
}
// Fill output (modify *Handles)
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);
// - Also, de-register
ret = VFS_int_Select_Deregister(thisthread, MaxHandle, ReadHandles, 0, IsKernel);
ret += VFS_int_Select_Deregister(thisthread, MaxHandle, WriteHandles, 1, IsKernel);
@@
-196,6
+198,7
@@
int VFS_Select(int MaxHandle, fd_set *ReadHandles, fd_set *WriteHandles, fd_set
// Mark a node as having data ready for reading
int VFS_MarkAvaliable(tVFS_Node *Node, BOOL IsDataAvaliable)
{
// 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 )
ENTER("pNode bIsDataAvaliable", Node, IsDataAvaliable);
Node->DataAvaliable = !!IsDataAvaliable;
if( Node->DataAvaliable )
@@
-207,6
+210,7
@@
int VFS_MarkAvaliable(tVFS_Node *Node, BOOL IsDataAvaliable)
// Mark a node as having a full buffer
int VFS_MarkFull(tVFS_Node *Node, BOOL IsBufferFull)
{
// 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 )
ENTER("pNode bIsBufferFull", Node, IsBufferFull);
Node->BufferFull = !!IsBufferFull;
if( !Node->BufferFull )
@@
-218,6
+222,7
@@
int VFS_MarkFull(tVFS_Node *Node, BOOL IsBufferFull)
// Mark a node as errored
int VFS_MarkError(tVFS_Node *Node, BOOL IsErrorState)
{
// 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 )
ENTER("pNode bIsErrorState", Node, IsErrorState);
Node->ErrorOccurred = !!IsErrorState;
if( Node->ErrorOccurred )
UCC
git Repository :: git.ucc.asn.au