status_t
ResolveValueNodeValueJob::_ResolveParentNodeValue(ValueNode* parentNode)
{
	AutoLocker<ValueNodeContainer> containerLocker(fContainer);

	if (parentNode->Container() != fContainer)
		return B_BAD_VALUE;

	// if the parent node already has a value, we're done
	status_t nodeResolutionState
		= parentNode->LocationAndValueResolutionState();
	if (nodeResolutionState != VALUE_NODE_UNRESOLVED)
		return nodeResolutionState;

	// check whether a job is already in progress
	AutoLocker<Worker> workerLocker(GetWorker());
	SimpleJobKey jobKey(parentNode, JOB_TYPE_RESOLVE_VALUE_NODE_VALUE);
	if (GetWorker()->GetJob(jobKey) == NULL) {
		workerLocker.Unlock();

		// schedule the job
		status_t error = GetWorker()->ScheduleJob(
			new(std::nothrow) ResolveValueNodeValueJob(fDebuggerInterface,
				fArchitecture, fCpuState, fTypeInformation, fContainer,
				parentNode));
		if (error != B_OK) {
			// scheduling failed -- set the value to invalid
			parentNode->SetLocationAndValue(NULL, NULL, error);
			return error;
		}
	}

	// wait for the job to finish
	workerLocker.Unlock();
	containerLocker.Unlock();

	switch (WaitFor(jobKey)) {
		case JOB_DEPENDENCY_SUCCEEDED:
		case JOB_DEPENDENCY_NOT_FOUND:
			// "Not found" can happen due to a race condition between
			// unlocking the worker and starting to wait.
			break;
		case JOB_DEPENDENCY_ACTIVE:
			return B_OK;
		case JOB_DEPENDENCY_FAILED:
		case JOB_DEPENDENCY_ABORTED:
		default:
			return B_ERROR;
	}

	containerLocker.Lock();

	// now there should be a value for the node
	nodeResolutionState = parentNode->LocationAndValueResolutionState();
	return nodeResolutionState != VALUE_NODE_UNRESOLVED
		? nodeResolutionState : B_ERROR;
}
Exemple #2
0
Fichier : Pcd.c Projet : b-man/edk2
EFIAPI
DxePcdGetPtr (
  IN UINTN                     TokenNumber
  )
{
  return GetWorker (TokenNumber, 0);
}
Exemple #3
0
Fichier : Pcd.c Projet : b-man/edk2
/**
  Retrieves a Boolean value for a given PCD token.

  Retrieves the current boolean value for a PCD token number.
  Do not make any assumptions about the alignment of the pointer that
  is returned by this function call.  If the TokenNumber is invalid,
  the results are unpredictable.

  @param[in]  TokenNumber The PCD token number.

  @return The Boolean value.

**/
BOOLEAN
EFIAPI
DxePcdGetBool (
  IN UINTN                     TokenNumber
  )
{
  return *((BOOLEAN *) GetWorker (TokenNumber, sizeof (BOOLEAN)));
}
Exemple #4
0
Fichier : Pcd.c Projet : b-man/edk2
/**
  Retrieves an 64-bit value for a given PCD token.

  Retrieves the current 64-bits value for a PCD token number.
  If the TokenNumber is invalid, the results are unpredictable.

  @param[in]  TokenNumber The PCD token number.

  @return The UINT64 value.

**/
UINT64
EFIAPI
DxePcdGet64 (
  IN UINTN                     TokenNumber
  )
{
  return ReadUnaligned64(GetWorker (TokenNumber, sizeof (UINT64)));
}
Exemple #5
0
Fichier : Pcd.c Projet : b-man/edk2
/**
  Retrieves an 32-bit value for a given PCD token.

  Retrieves the current 32-bits value for a PCD token number.
  If the TokenNumber is invalid, the results are unpredictable.

  @param[in]  TokenNumber The PCD token number.

  @return The UINT32 value.

**/
UINT32
EFIAPI
DxePcdGet32 (
  IN UINTN                    TokenNumber
  )
{
  return ReadUnaligned32 (GetWorker (TokenNumber, sizeof (UINT32)));
}
Exemple #6
0
Fichier : Pcd.c Projet : b-man/edk2
/**
  Retrieves an 16-bit value for a given PCD token.

  Retrieves the current 16-bits value for a PCD token number.
  If the TokenNumber is invalid, the results are unpredictable.

  @param[in]  TokenNumber The PCD token number.

  @return The UINT16 value.

**/
UINT16
EFIAPI
DxePcdGet16 (
  IN UINTN                    TokenNumber
  )
{
  return ReadUnaligned16 (GetWorker (TokenNumber, sizeof (UINT16)));
}
Exemple #7
0
Fichier : Pcd.c Projet : b-man/edk2
/**
  Retrieves an 8-bit value for a given PCD token.

  Retrieves the current byte-sized value for a PCD token number.
  If the TokenNumber is invalid, the results are unpredictable.

  @param[in]  TokenNumber The PCD token number.

  @return The UINT8 value.

**/
UINT8
EFIAPI
DxePcdGet8 (
  IN UINTN                    TokenNumber
  )
{
  return *((UINT8 *) GetWorker (TokenNumber, sizeof (UINT8)));
}
Exemple #8
0
/**
  Wrapper function for get PCD value for dynamic-ex PCD.

  @param Guid            Token space guid for dynamic-ex PCD.
  @param ExTokenNumber   Token number for dyanmic-ex PCD.
  @param GetSize         The size of dynamic-ex PCD value.

  @return PCD entry in PCD database.

**/
VOID *
ExGetWorker (
  IN CONST  EFI_GUID  *Guid,
  IN UINTN            ExTokenNumber,
  IN UINTN            GetSize
  )
{ 
  return GetWorker (GetExPcdTokenNumber (Guid, ExTokenNumber), GetSize);
}
BOOL CScheduleJob::StartWorker(PFNWORKERPROC pfnWorker, void *pJob)
{
	int		nIndex;

	nIndex = GetWorker();
	if (nIndex == -1)
		return FALSE;

	m_Worker[nIndex].StartJob(m_pCaller, (void *)this, StartJob, EndJob, pfnWorker, pJob);	
	return TRUE;
}
void WorkerManager::RegisterTask(const shared_ptr<Task>& task)
{
	AutoLocker lock(m_critSec);

	while(true) {
		if(IsCancelPending()) {
			return;
		}

		shared_ptr<WorkerThread> worker = GetWorker();
		if(!worker->AssignTask(task)) {
			continue;
		}

		RegisterActiveWorker(worker);
		return;
	}
}
Exemple #11
0
//
// Remove worker from indicated manager.  Update indexes for other
// workers.  This function must be called before removing the worker
// from the list of workers.
//
void CWorkerView::RemoveWorker(Worker * worker)
{
	// Get the worker tree item.
	HTREEITEM hworker = GetWorker(worker);

	// If removing a server with an active partner, remove partner as well.
	if (IsType(worker->Type(), GenericServerType) && worker->net_partner) {
		// Call RemoveWorker recursively to remove the NetClient from the GUI.
		RemoveWorker(worker->net_partner);
	}
	// Remove the indicated worker from memory.
	worker->manager->RemoveWorker(worker->GetIndex());

	// Remove the indicated worker from the display.
	m_TWorkers.DeleteItem(hworker);
	m_TWorkers.RedrawWindow();

	// Reset the results display tab to its initial state.
	theApp.pView->m_pPageDisplay->Reset();
}
Exemple #12
0
status_t
GetStackTraceJob::GetImageDebugInfo(Image* image, ImageDebugInfo*& _info)
{
    AutoLocker<Team> teamLocker(fThread->GetTeam());

    while (image->GetImageDebugInfo() == NULL) {
        // schedule a job, if not loaded
        ImageDebugInfo* info;
        status_t error = LoadImageDebugInfoJob::ScheduleIfNecessary(GetWorker(),
                         image, &info);
        if (error != B_OK)
            return error;

        if (info != NULL) {
            _info = info;
            return B_OK;
        }

        teamLocker.Unlock();

        // wait for the job to finish
        switch (WaitFor(SimpleJobKey(image, JOB_TYPE_LOAD_IMAGE_DEBUG_INFO))) {
        case JOB_DEPENDENCY_SUCCEEDED:
        case JOB_DEPENDENCY_NOT_FOUND:
            // "Not found" can happen due to a race condition between
            // unlocking the worker and starting to wait.
            break;
        case JOB_DEPENDENCY_FAILED:
        case JOB_DEPENDENCY_ABORTED:
        default:
            return B_ERROR;
        }

        teamLocker.Lock();
    }

    _info = image->GetImageDebugInfo();
    _info->AcquireReference();

    return B_OK;
}
Exemple #13
0
//
// Select the specified item in the worker tree view and scroll it into view.
// If both mgr and wkr params are NULL, "All Managers" will be selected.
// If mgr points to a valid manager and wkr is NULL, the manager will be selected.
// If mgr and wkr are both defined, the appropriate worker on the specified
// manager will be selected.
//
void CWorkerView::SelectItem(Manager * mgr, Worker * wkr)
{
	HTREEITEM item;

	if (mgr) {
		if (wkr) {
			// The bar is monitoring a worker on the specified manager.
			// Find the HTREEITEM corresponding to the worker.
			item = GetWorker(wkr);
		} else {
			// The bar is monitoring a manager.
			// Find the HTREEITEM corresponding to the manager.
			item = GetManager(mgr);
		}
	} else {
		// The bar is monitoring "All Managers".
		// Find the HTREEITEM corresponding to "All Managers".
		item = m_TWorkers.GetRootItem();
	}

	// Select the item and scroll it into view.
	m_TWorkers.Select(item, TVGN_CARET);
	m_TWorkers.EnsureVisible(item);
}
Exemple #14
0
//
// User renamed one of the workers.  Updating the information in
// the worker list.
//
void CWorkerView::OnEndlabeleditTWorkers(NMHDR * pNMHDR, LRESULT * pResult)
{
	TV_DISPINFO *pTVDispInfo = (TV_DISPINFO *) pNMHDR;
	CString new_name = pTVDispInfo->item.pszText;

	// Don't allow renaming of "All Managers" or network clients.
	if (pTVDispInfo->item.mask & TVIF_TEXT && (selected_type == MANAGER || selected_type == WORKER)
	    && !IsType(GetSelectedWorkerType(), GenericClientType)) {
		// Don't allow any leading or trailing spaces.
		new_name.TrimLeft();
		new_name.TrimRight();

		// It's okay to put the string back into the array of unknown
		// size because we know we have not lengthened the string.
		strcpy(pTVDispInfo->item.pszText, (LPCTSTR) new_name);

		if (!new_name.IsEmpty()) {
			// New name is non-empty; change it.  (If new name is an empty string, 
			// do nothing -- old name remains unchanged.)

			if (selected_type == WORKER) {
				// Modify worker's name.
				strcpy(GetSelectedWorker()->name, pTVDispInfo->item.pszText);

				// Assign disambiguating integer identifiers to same-named managers.
				GetSelectedManager()->IndexWorkers();
			} else {
				// Modify manager's name.
				strcpy(GetSelectedManager()->name, pTVDispInfo->item.pszText);
				theApp.pView->m_pPageNetwork->ShowData();

				// Assign disambiguating integer identifiers to same-named managers.
				theApp.manager_list.IndexManagers();
			}

			// Changing name of selected item.
			m_TWorkers.SetItemText(m_TWorkers.GetSelectedItem(), pTVDispInfo->item.pszText);

			// See if a network server worker is selected.
			if (IsType(GetSelectedWorkerType(), GenericServerType)) {
				Worker *server = GetSelectedWorker();

				// See if this server has a client worker assigned to it.
				if (server->net_partner) {
					// Change the worker's name.
					strcpy(server->net_partner->name,
					       "[" + (CString) pTVDispInfo->item.pszText + "]");

					// Update the tree control to reflect the new name.
					m_TWorkers.SetItemText(GetWorker(server->net_partner),
							       server->net_partner->name);
				}
			}
			// Re-sort the manager list.
			m_TWorkers.SortChildren(m_TWorkers.GetRootItem());

			// Update the Results Display page.
			theApp.pView->m_pPageDisplay->Update();
		}
	}

	editing_label = FALSE;
	if (old_label_name) {
		delete old_label_name;

		old_label_name = NULL;
	}
	*pResult = 0;
}