KERNEL_CALL_ERROR(RunningTask>=NUMBER_OF_MAIL_TASKS,INVALID_TASK);
KERNEL_CALL_ERROR(RunningInst>KernelGetMaxInstance(RunningTask),INVALID_INSTANCE);
KERNEL_CALL_ERROR(Func==NULL,INVALID_TASK_FUNC);

if ( (QueueType *)MQ_Pointer != MQ_Tail) { /* * There are mails in the queue. */ MQ_Next = *MQ_Pointer; if (MQ_Next != MQ_Tail) { /* * There are more waiting mails. * Set the queue pointer to the next waiting mail. * This will indirectly set MQ_Root to the next queue entry! */ *MQ_Pointer= MQ_Next->Next; } else { /* * This was the last waiting mail, so the end equals to the beginning. */ MQ_Tail = (QueueType *)MQ_Pointer; } KernelData.MailCount--; OS_LeaveCriticalSection(); KSCHED_PRINT("KernelIsQueuedMail(): Mail removed from Queue.") return TRUE; }

static unsigned int RandValue;

unsigned int OS_Rand ( void )
{
      RandValue = ((RandValue * 214013L + 2531011L) >> 16);
 
      return (0 == RandValue) ?  42  :  RandValue;
}

MailType *m; KERNEL_CALL_ERROR(p==NULL,INVALID_PIPE); m = p->head; if (m != NULL) { KERNEL_CHECK_POINTER(m); if (m == p->tail) { p->tail = p->head = NULL; } else { p->head = p->head->Next; } #ifdef _KERNEL_DEBUG_ p->count--; KERNEL_CALLPF_P2("OS_DePipe(): 0x%p, p->count: %d", (LONG_PTR)m,p->count) #endif }

KERNEL_CALL_ERROR(p==NULL,INVALID_PIPE); KERNEL_CHECK_POINTER(m); if (p->head == NULL) { p->head = p->tail = m; } else { p->tail->Next = m; p->tail = m; } #ifdef _KERNEL_DEBUG_ p->count++; KERNEL_CALLPF_P2("OS_EnPipe(): 0x%p, p->count: %d", (LONG_PTR)m,p->count) #endif

 

 

 

 

 

 

 

 


{ DWORD ThreadId = GetCurrentThreadId(); KERNEL_TRACEF_P1("OS_RaiseError(): Called from THREAD %08X.", ThreadId) if (_ErrorCount_) { /* * No reentrant call to OS_RaiseError(). */ KERNEL_TRACE("- Reentrant called, ignore.") return; } if (ThreadId == dwMainThread) { /* * We try to raise the error later, * because terminating the Main thread would end the whole application! */ KERNEL_TRACE("- Called from Main thread, ignore.") TargetCheckAndLeaveCriticalSection(); return; } if (InterlockedExchange((long*)&_RaiseError_, FALSE) == FALSE) { KERNEL_TRACEF_P1("- OS_RaiseError already done, terminate thread.\nTHREAD %08X Exit 1.", ThreadId) /* * A thread raised the error before. * All other threads can be terminated now. */ _endthreadex(1); } _set_to(_RaiseError_, FALSE); /* * No more action from interrupt threads! */ TargetDisableInterrupt(); /* * The current thread now makes an emergency end ... * Check leave critical section counter, clear and leave critical section. * This function is for the emergency exit to leave the current thread with * a left g_CriticalSection. So other threads which are waiting for the * Critical Section must not hang any more! */ TargetCheckAndLeaveCriticalSection(); /* * Popup window with ok button. */ WS_MainFatalException ( FIRMWARE_EXCEPTION, (LPCTSTR) szWinErrorStr ); DBTRACE( WS_ThreadPrint(__TEXT("THREAD:"),__TEXT("Exit 1"), ThreadId) ); // test: // __DebugBreak(); _endthreadex(1); }


 


Disclaimer

 

$Date: 2010-01-30 15:38:03+01 $
$Revision: 1.4 $