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
And, adding a rather important header that I fogot in the heap rewrite
[tpg/acess2.git]
/
Kernel
/
messages.c
diff --git
a/Kernel/messages.c
b/Kernel/messages.c
index
32e579b
..
4765d65
100644
(file)
--- a/
Kernel/messages.c
+++ b/
Kernel/messages.c
@@
-34,10
+34,13
@@
int Proc_SendMessage(Uint *Err, Uint Dest, int Length, void *Data)
if(!thread) { return -1; }
// Get Spinlock
if(!thread) { return -1; }
// Get Spinlock
- LOCK( &thread->IsLocked );
+
SHORT
LOCK( &thread->IsLocked );
// Check if thread is still alive
// Check if thread is still alive
- if(thread->Status == THREAD_STAT_DEAD) return -1;
+ if(thread->Status == THREAD_STAT_DEAD) {
+ SHORTREL( &thread->IsLocked );
+ return -1;
+ }
// Create message
msg = malloc( sizeof(tMsg)+Length );
// Create message
msg = malloc( sizeof(tMsg)+Length );
@@
-55,7
+58,7
@@
int Proc_SendMessage(Uint *Err, Uint Dest, int Length, void *Data)
thread->LastMessage = msg;
}
thread->LastMessage = msg;
}
-
RELEASE
(&thread->IsLocked);
+
SHORTREL
(&thread->IsLocked);
Threads_Wake( thread );
Threads_Wake( thread );
@@
-72,7
+75,7
@@
int Proc_SendMessage(Uint *Err, Uint Dest, int Length, void *Data)
int Proc_GetMessage(Uint *Err, Uint *Source, void *Buffer)
{
int ret;
int Proc_GetMessage(Uint *Err, Uint *Source, void *Buffer)
{
int ret;
- void *tmp;
+ void
*tmp;
tThread *cur = Proc_GetCurThread();
// Check if queue has any items
tThread *cur = Proc_GetCurThread();
// Check if queue has any items
@@
-80,7
+83,7
@@
int Proc_GetMessage(Uint *Err, Uint *Source, void *Buffer)
return 0;
}
return 0;
}
- LOCK( &cur->IsLocked );
+
SHORT
LOCK( &cur->IsLocked );
if(Source)
*Source = cur->Messages->Source;
if(Source)
*Source = cur->Messages->Source;
@@
-88,7
+91,7
@@
int Proc_GetMessage(Uint *Err, Uint *Source, void *Buffer)
// Get message length
if( !Buffer ) {
ret = cur->Messages->Length;
// Get message length
if( !Buffer ) {
ret = cur->Messages->Length;
-
RELEASE
( &cur->IsLocked );
+
SHORTREL
( &cur->IsLocked );
return ret;
}
return ret;
}
@@
-98,7
+101,7
@@
int Proc_GetMessage(Uint *Err, Uint *Source, void *Buffer)
if( !CheckMem( Buffer, cur->Messages->Length ) )
{
*Err = -EINVAL;
if( !CheckMem( Buffer, cur->Messages->Length ) )
{
*Err = -EINVAL;
-
RELEASE
( &cur->IsLocked );
+
SHORTREL
( &cur->IsLocked );
return -1;
}
memcpy(Buffer, cur->Messages->Data, cur->Messages->Length);
return -1;
}
memcpy(Buffer, cur->Messages->Data, cur->Messages->Length);
@@
-106,11
+109,12
@@
int Proc_GetMessage(Uint *Err, Uint *Source, void *Buffer)
ret = cur->Messages->Length;
// Remove from list
ret = cur->Messages->Length;
// Remove from list
- tmp = cur->Messages->Next;
- free( (void*)cur->Messages );
- cur->Messages = tmp;
+ tmp = cur->Messages;
+ cur->Messages = cur->Messages->Next;
+
+ SHORTREL( &cur->IsLocked );
- RELEASE( &cur->IsLocked );
+ free(tmp); // Free outside of lock
return ret;
}
return ret;
}
UCC
git Repository :: git.ucc.asn.au