Exemplo n.º 1
0
DWORD InterfaceUtils::CleanUP() {
	// This example assumes that the SLIST_ENTRY structure is the 
	// first member of the structure. If your structure does not 
	// follow this convention, you must compute the starting address 
	// of the structure before calling the free function.
	while (true) {
		pListEntry = InterlockedPopEntrySList(pListHead);
		if (NULL == pListEntry)
		{
			printf("List is empty.\n");
			break;
		}
		pProgramItem = (PPROGRAM_ITEM)pListEntry;
		InterfaceDeleteIPAddress(pProgramItem->NTEContext);
		_aligned_free(pListEntry);
	}
	pListEntry = InterlockedFlushSList(pListHead);
	pFirstEntry = InterlockedPopEntrySList(pListHead);
	if (pFirstEntry != NULL) {
		printf("Error: List is not empty.\n");
		return -1;
	}
	_aligned_free(pListHead);
	return NO_ERROR;
}
Exemplo n.º 2
0
static unsigned __stdcall
winmm_buffer_thread(void * user_ptr)
{
  cubeb * ctx = (cubeb *) user_ptr;
  XASSERT(ctx);

  for (;;) {
    DWORD r;
    PSLIST_ENTRY item;

    r = WaitForSingleObject(ctx->event, INFINITE);
    XASSERT(r == WAIT_OBJECT_0);

    /* Process work items in batches so that a single stream can't
       starve the others by continuously adding new work to the top of
       the work item stack. */
    item = InterlockedFlushSList(ctx->work);
    while (item != NULL) {
      PSLIST_ENTRY tmp = item;
      winmm_refill_stream(((struct cubeb_stream_item *) tmp)->stream);
      item = item->Next;
      _aligned_free(tmp);
    }

    if (ctx->shutdown) {
      break;
    }
  }

  return 0;
}
Exemplo n.º 3
0
void freerdp_channels_free(rdpChannels* channels)
{
	rdpChannelsList* list;
	rdpChannelsList* prev;

	InterlockedFlushSList(channels->pSyncDataList);
	_aligned_free(channels->pSyncDataList);

	CloseHandle(channels->event_sem);
	CloseHandle(channels->signal);

	/* Remove from global list */

	WaitForSingleObject(g_mutex_list, INFINITE);

	for (prev = NULL, list = g_channels_list; list; prev = list, list = list->next)
	{
		if (list->channels == channels)
			break;
	}

	if (list)
	{
		if (prev)
			prev->next = list->next;
		else
			g_channels_list = list->next;
		free(list);
	}

	ReleaseMutex(g_mutex_list);

	free(channels);
}
Exemplo n.º 4
0
    /// <summary>
    ///     Returns all items on the UMS completion list.  Note that this indirectly manipulates the transfer list.  This
    ///     will literally dequeue everything from BOTH lists and hand it to the caller.
    /// </summary>
    /// <returns>
    ///     The first UMSThreadProxy on the completion list.
    /// </returns>
    UMSThreadProxy *UMSSchedulerProxy::GetCompletionListItems()
    {
        SweepCompletionList();

        InterlockedExchange(&m_pushedBackCount, 0);

        //
        // Yep, there's a race where we could inadvertently set the event for an item which is pushed in this window from another thread
        // but popped right here.  The worst thing that comes out of said race is an extra awakening of a virtual processor to check
        // an empty completion list.
        //

        PSLIST_ENTRY pItem = InterlockedFlushSList(&m_transferList);
        UMSThreadProxy *pProxy = pItem == NULL ? NULL : CONTAINING_RECORD(pItem, UMSThreadProxy, m_listEntry);

#if defined(_DEBUG)
        UMSThreadProxy *pTrav = pProxy;
        while (pTrav != NULL)
        {
            pTrav->m_UMSDebugBits |= UMS_DEBUGBIT_PULLEDFROMTRANSFERLIST;
            pTrav = static_cast<UMSThreadProxy *>(pTrav->GetNextUnblockNotification());
        }
#endif // _DEBUG

        return pProxy;
    }
Exemplo n.º 5
0
// ******************************************************************
// * 0x0038 - InterlockedFlushSList()
// ******************************************************************
// Source:ReactOS
// Dxbx Note : The Xbox1 SINGLE_LIST strucures are the same as in WinNT
XBSYSAPI EXPORTNUM(56) xboxkrnl::PSINGLE_LIST_ENTRY FASTCALL xboxkrnl::KRNL(InterlockedFlushSList)
(
	IN xboxkrnl::PSLIST_HEADER ListHead
)
{
	LOG_FUNC_ONE_ARG(ListHead);

	PSINGLE_LIST_ENTRY res = (PSINGLE_LIST_ENTRY)InterlockedFlushSList((::PSLIST_HEADER)ListHead);

	RETURN(res);
}
Exemplo n.º 6
0
VOID CALLBACK 
HttpListenerFlushLookasideThreadProc(
  __in  PVOID lpParameter,
  __in  BOOLEAN TimerOrWaitFired
)
{  
	PHTTP_LISTENER listener = (PHTTP_LISTENER)lpParameter;
    ULONG Index;  
    PSLIST_ENTRY List;  
    PSLIST_ENTRY NextEntry;  
   
	// TODO: Queue on timer
	printf("Freeing context\n");          
    for (Index = 0; Index < MAX_IO_CONTEXT_PROCESSOR_CACHE; Index++)  
    {              
        List = InterlockedFlushSList(&IoContextCacheList[Index].Header);            
        while (List != NULL)  
        {
            NextEntry = List->Next;  
			FREE_MEM(CONTAINING_RECORD(List, HTTP_IO_CONTEXT, LookAsideEntry));  
            List = NextEntry;  
        }                
    }  
}  
Exemplo n.º 7
0
int TestInterlockedSList(int argc, char* argv[])
{
	ULONG Count;
	WINPR_PSLIST_ENTRY pFirstEntry;
	WINPR_PSLIST_ENTRY pListEntry;
	WINPR_PSLIST_HEADER pListHead;
	PPROGRAM_ITEM pProgramItem;

	/* Initialize the list header to a MEMORY_ALLOCATION_ALIGNMENT boundary. */
	pListHead = (WINPR_PSLIST_HEADER) _aligned_malloc(sizeof(WINPR_SLIST_HEADER), MEMORY_ALLOCATION_ALIGNMENT);

	if (!pListHead)
	{
		printf("Memory allocation failed.\n");
		return -1;
	}

	InitializeSListHead(pListHead);

	/* Insert 10 items into the list. */
	for (Count = 1; Count <= 10; Count += 1)
	{
		pProgramItem = (PPROGRAM_ITEM) _aligned_malloc(sizeof(PROGRAM_ITEM), MEMORY_ALLOCATION_ALIGNMENT);

		if (!pProgramItem)
		{
			printf("Memory allocation failed.\n");
			return -1;
		}

		pProgramItem->Signature = Count;
		pFirstEntry = InterlockedPushEntrySList(pListHead, &(pProgramItem->ItemEntry));
	}

	/* Remove 10 items from the list and display the signature. */
	for (Count = 10; Count >= 1; Count -= 1)
	{
		pListEntry = InterlockedPopEntrySList(pListHead);

		if (!pListEntry)
		{
			printf("List is empty.\n");
			return -1;
		}
  
		pProgramItem = (PPROGRAM_ITEM) pListEntry;
		printf("Signature is %d\n", (int) pProgramItem->Signature);

		/* 
		 * This example assumes that the SLIST_ENTRY structure is the 
		 * first member of the structure. If your structure does not 
		 * follow this convention, you must compute the starting address 
		 * of the structure before calling the free function.
		 */

		_aligned_free(pListEntry);
	}

	/* Flush the list and verify that the items are gone. */
	pListEntry = InterlockedFlushSList(pListHead);
	pFirstEntry = InterlockedPopEntrySList(pListHead);

	if (pFirstEntry)
	{
		printf("Error: List is not empty.\n");
		return -1;
	}

	_aligned_free(pListHead);

	return 0;
}
Exemplo n.º 8
0
	SListEntry* SListImpl::flush()
	{
		return reinterpret_cast<SListEntry*>(InterlockedFlushSList(getDetail(this)));
	}
Exemplo n.º 9
0
	~SNIMemRegion()
	{
		InterlockedFlushSList(&m_SListHeader);
	}