}
/**
- * \fn int Proc_Execve(char *File, char **ArgV, char **EnvP)
* \brief Replace the current user image with another
* \param File File to load as the next image
* \param ArgV Arguments to pass to user
argenvBytes += strlen(ArgV[argc])+1;
for( envc = 0; EnvP && EnvP[envc]; envc++ )
argenvBytes += strlen(EnvP[envc])+1;
+ LOG("argc = %i, envc = %i", envc);
argenvBytes = (argenvBytes + sizeof(void*)-1) & ~(sizeof(void*)-1);
argenvBytes += (argc+1)*sizeof(void*) + (envc+1)*sizeof(void*);
{
argvSaved[i] = strBuf;
strcpy(argvSaved[i], ArgV[i]);
+ LOG("argv[%i] = '%s'", i, strBuf);
strBuf += strlen(ArgV[i])+1;
}
argvSaved[i] = NULL;
for( i = 0; i < envc; i++ )
{
envpSaved[i] = strBuf;
+ LOG("envp[%i] = '%s'", i, strBuf);
strcpy(envpSaved[i], EnvP[i]);
strBuf += strlen(EnvP[i])+1;
}
// Configuration
#define DEBUG_TRACE_TICKETS 0 // Trace ticket counts
#define DEBUG_TRACE_STATE 0 // Trace state changes (sleep/wake)
-#define SEMAPHORE_DEBUG 0
+#define SEMAPHORE_DEBUG 0 // Debug semaphores
// --- Schedulers ---
#define SCHED_UNDEF 0
}
break;
- // Brains!... You cannot kill
+ // Brains!... You cannot kill something that is already dead
case THREAD_STAT_ZOMBIE:
Log_Warning("Threads", "Threads_Kill - Thread %p(%i,%s) is undead, you cannot kill it",
Thread, Thread->TID, Thread->ThreadName);
// Save exit status
Thread->RetStatus = Status;
+ SHORTREL( &Thread->IsLocked );
+
// Don't Zombie if we are being killed because our parent is
if(Status == -1)
{
Log("Thread %i went *hurk* (%i)", Thread->TID, Status);
- // Release spinlocks
- SHORTREL( &Thread->IsLocked ); // TODO: We may not actually be released...
-
// And, reschedule
if(isCurThread)
{
/**
- * \fn int Threads_Wake( tThread *Thread )
* \brief Wakes a sleeping/waiting thread up
* \param Thread Thread to wake
* \return Boolean Failure (Returns ERRNO)
sem->LastSignaling = prev;
}
+ Thread->RetStatus = 0; // It didn't get anything
Threads_AddActive( Thread );
#if DEBUG_TRACE_STATE
#endif
SHORTREL( &Sem->Protector ); // Release first to make sure it is released
- SHORTREL( &glThreadListLock );
- while(us->Status == THREAD_STAT_SEMAPHORESLEEP) Threads_Yield();
+ SHORTREL( &glThreadListLock );
+ while( us->Status == THREAD_STAT_SEMAPHORESLEEP )
+ {
+ Threads_Yield();
+ if(us->Status == THREAD_STAT_SEMAPHORESLEEP)
+ Log_Warning("Threads", "Semaphore %p %s:%s re-schedulued while asleep",
+ Sem, Sem->ModName, Sem->Name);
+ }
+ #if DEBUG_TRACE_STATE || SEMAPHORE_DEBUG
+ Log("Semaphore %p %s:%s woken", Sem, Sem->ModName, Sem->Name);
+ #endif
// We're only woken when there's something avaliable (or a signal arrives)
us->WaitPointer = NULL;
}
SHORTREL( &Sem->Protector );
+ #if DEBUG_TRACE_STATE || SEMAPHORE_DEBUG
+ Log("Semaphore %p %s:%s took %i by wait",
+ Sem, Sem->ModName, Sem->Name, taken);
+ #endif
+
return taken;
}