コード例 #1
0
void CRUTopologicalDGIterator::Next()
{
	RUASSERT(FALSE == allTasksLinkMap_.IsEmpty());

	CRUTask *pTask = GetCurrentTask();
	if (NULL == pTask)
	{
		return; // all the tasks have been already traversed
	}

	// The tasks that need to be traversed after me
	CRUTaskList &refTaskList = 
		(DIRECT == dir_) ? 
			pTask->GetTasksThatDependOnMe() :
			pTask->GetTasksThatIDependOn();

	// For all of these tasks, decrecase the reference count
	// Update the "ready" list, if any of the tasks have become ready.
	UpdateIterator(refTaskList);

	// Select a new current task
	if (TRUE == readyTasksList_.IsEmpty())
	{
		SetCurrentTask(NULL); // The last task has just been traversed
	}
	else
	{
		// Retrieve a new task from the "ready" list
		SetCurrentTask(readyTasksList_.RemoveHead());
	}
}
コード例 #2
0
ファイル: tee_scheduler.c プロジェクト: HappyASR/Trust-E-OS
void TaskSwitch()
{
    TASK *current,*next;
    current = TaskCurrent();
    next = TaskNextReady();
    if (next) { 
        if (current) {
            // 如果当前任务是主任务(即第一个任务main),
            // 则将其继续加入就绪列表,不要挂起
            if (current->task_id == TASK_ID_START) {
                current->task_status = TASK_READY;
                TaskAddReady(current);
            }
            else {
                current->task_status = TASK_SUSPUD; 
                TaskAddSuspud(current);
                TEE_Printf("in task switch...\n"); 
            }
            TEE_MemMove(&current->core_regs, &g_temp_regs, sizeof(CPU_CORE_REGS));
        }
        next->task_status = TASK_RUNNING;
        SetCurrentTask(next);
        TaskDelReady(next);
        TEE_MemMove(&g_temp_regs, &next->core_regs, sizeof(CPU_CORE_REGS));
    }
}
コード例 #3
0
void CRUTopologicalDGIterator::Build()
{
	TaskLink link;

	// Fill the data structures by references to available tasks
	DSListPosition pos = GetAllTasksList().GetHeadPosition();
	while (NULL != pos)
	{
		CRUTask *pTask = GetAllTasksList().GetNext(pos);
		link.pTask_ = pTask;

		// The tasks that need to be traversed before me
		CRUTaskList &refTaskList =
			(DIRECT == dir_) ? 
				pTask->GetTasksThatIDependOn() :
				pTask->GetTasksThatDependOnMe();
			
		link.refCount_ = refTaskList.GetCount();
		
		// Place the link into the hash
		allTasksLinkMap_[pTask->GetId()] = link;

		// If this is a ready task, 
		// place a reference to it into the ready list
		if (0 == link.refCount_)
		{
			readyTasksList_.AddHead(link.pTask_);
		}
	}

	// My guess is that this is a circular graph
	RUASSERT(FALSE == readyTasksList_.IsEmpty()); 

	SetCurrentTask(readyTasksList_.RemoveHead());
}
コード例 #4
0
XLinuxTask* XLinuxTaskMgr::CreateMain(VTask* inOwner)
{
	XLinuxTask* task=new XLinuxTask_preemptive(inOwner, true);
	inOwner->SetCanBlockOnSyncObject(true);	//BUG ICI ???

	SetCurrentTask(inOwner);

	return task;
}