예제 #1
0
int main()
{

	lock = CreateLock("lock");
	cv2 = CreateCV("cv2");
	
	AcquireLock("lock");

	SignalCV("lock","cv2");

	Print("Client 3 will now destroy CV...",-1,-1,-1);
	
	DestroyCV("cv2");
	
	for (i=0; i<9; i++)
		Print("\n",-1,-1,-1);


	ReleaseLock("lock");

	AcquireLock("lock");	
	
	WaitCV("lock","cv2");
	
	Print("Client 3: This prints as CV has been destroyed...",-1,-1,-1);

	ReleaseLock("lock");

	Exit(0);

}
예제 #2
0
파일: otudp.c 프로젝트: CNMAT/CNMAT-Externs
void otudp_output(OTUDP *x) {
	// This is called by the Max clock.  It's guaranteed not to be called
	// at notifier level, although if we're in Overdrive this will be called
	// at interrupt level.
	Atom arguments[2];
	PacketBuffer b;
	short oldLockout;

	
	// BufferSanityCheck(x, 0, 0, 0);

	while (1) {
		oldLockout = AcquireLock(x);
		b = PBFIFODequeue(&(x->pendingBuffers));
		ReleaseLock(x,oldLockout);
		
		if (b == 0) break;
		
		SETLONG(&arguments[0], b->n);
		SETLONG(&arguments[1], (long) b->buf);
		outlet_anything(x->o_outlet, ps_FullPacket, 2, arguments);
		
		oldLockout = AcquireLock(x);
		PacketBufferListPush(b, &(x->freeBuffers));
		ReleaseLock(x,oldLockout);		
		
	}
	
	// BufferSanityCheck(x, 0, 0, 0);
}
예제 #3
0
	void ReleaseProcessMemory(HANDLE hProc)
	{
		DWORD pid,addr,len;
		AcquireLock();
		if (hProc==NtCurrentProcess()) pid=current_process_id;
		else
		{
			PROCESS_BASIC_INFORMATION info;
			NtQueryInformationProcess(hProc,ProcessBasicInformation,&info,sizeof(info),&len);
			pid=info.uUniqueProcessId;
		}
		pid>>=2;
		//NtWaitForSingleObject(thread_man_mutex,0,0);
		for (UINT_PTR i=0;i<count;i++)
		{
			if ((proc_record[i]&0xFFF)==pid)
			{
				addr=proc_record[i]&~0xFFF;
				DWORD size=0x1000;
				NtFreeVirtualMemory(hProc,(PVOID*)&addr,&size,MEM_RELEASE);
				count--;
				for (UINT_PTR j=i;j<count;j++)
				{
					proc_record[j]=proc_record[j+1];
				}
				proc_record[count]=0;
				ReleaseLock();
				//NtReleaseMutant(thread_man_mutex,0);
				return;
			}
		}
		ReleaseLock();
		//NtReleaseMutant(thread_man_mutex,0);
	}
예제 #4
0
VOID  Image(IMG img, VOID *v){
        char    szFilePath[260];
        unsigned long index;
        
        GetLock(&lock, 1);
        if (process_start != 0){
                ReleaseLock(&lock);
                return;
        }
        if (IMG_Valid(img)){
                memset(szFilePath, 0, sizeof(szFilePath));
                strncpy(szFilePath, IMG_Name(img).c_str(), sizeof(szFilePath)-1);
                index = 0;
                while (szFilePath[index] != 0){
                        szFilePath[index] = tolower(szFilePath[index]);
                        index++;
                }
                
                if (strstr(szFilePath, KnobProcessToTrace.Value().c_str())){
                        process_start = IMG_LowAddress(img);
                        process_end   = IMG_HighAddress(img);
                }
        }
        ReleaseLock(&lock);
        
}
예제 #5
0
void main()
{
	lck = CreateLock("lock1");
	cv = CreateCV("cv1");
	Print("\nDistCVTest1_1: Created Lock is %d and CV is %d\n", lck, cv, -1);
	

	AcquireLock("lock1");

	
	Print("Client 1: About to go on wait...\n", -1, -1, -1);

	
	WaitCV("lock1","cv1");

	Print("Client 1: Now out of wait...\n", -1, -1, -1);

	for (num=0; num<10; num++)
		Print("\n",-1,-1,-1);
	
	Print("Client 1: About to signal Client 2\n", -1, -1, -1);
	
	SignalCV("lock1","cv1");

	ReleaseLock("lock1");
	AcquireLock("lock1");


	ReleaseLock("lock1");
	
	Exit(0);
	
	
}
예제 #6
0
파일: pi_par.c 프로젝트: pedrogrijo/MC723
int monte_carlo_pi(unsigned int n, int procNumber) {
	AcquireLock();
	printf("CORE %d\n", procNumber);
	ReleaseLock();
	int in = 0, i;
	int x, y, d;
        int limit;
	
        limit = n*(procNumber + 1)/CORES;
	if (procNumber == CORES - 1) {
		//ultimo core, faz o resto
		limit = n;
	}
	
	
	for (i = n*procNumber/CORES; i < limit; i++) {
		//x = ((*randNum % 1000000)/500000.0)-1;
		x = (((getRandomNumber() % 1000000)/500000)-1)*10;
		y = (((getRandomNumber() % 1000000)/500000)-1)*10;
		//y = ((*randNum % 1000000)/500000.0)-1;
		//x = 1;
		//y = 2;
		d = ((x*x) + (y*y));
		//AcquireLock();
		
		if (d <= 10) {
		  in+=1;
		}
		//ReleaseLock();
	}
	AcquireLock();
	printf("IN: %d\n", in);
	ReleaseLock();
	return in;
}
예제 #7
0
/*
 *----------------------------------------------------------------------
 *
 * OS_Accept --
 *
 *	Accepts a new FastCGI connection.  This routine knows whether
 *      we're dealing with TCP based sockets or NT Named Pipes for IPC.
 *
 * Results:
 *      -1 if the operation fails, otherwise this is a valid IPC fd.
 *
 * Side effects:
 *      New IPC connection is accepted.
 *
 *----------------------------------------------------------------------
 */
int OS_Accept(int listen_sock, int fail_on_intr, const char *webServerAddrs)
{
    int socket;
    union {
        struct sockaddr_un un;
        struct sockaddr_in in;
    } sa;

    for (;;) {
        if (AcquireLock(listen_sock, fail_on_intr))
            return -1;

        for (;;) {
            do {
                int len = sizeof(sa);
                socket = accept(listen_sock, (struct sockaddr *)&sa, &len);
            } while (socket < 0 && errno == EINTR && !fail_on_intr);

            if (socket < 0) {
                if (!is_reasonable_accept_errno(errno)) {
                    int errnoSave = errno;
                    ReleaseLock(listen_sock);
                    errno = errnoSave;
                    return (-1);
                }
                errno = 0;
            }
            else {  /* socket >= 0 */
                int set = 1;

                if (sa.in.sin_family != AF_INET)
                    break;

#ifdef TCP_NODELAY
                /* No replies to outgoing data, so disable Nagle */
                setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, (char *)&set, sizeof(set));
#endif

                /* Check that the client IP address is approved */
                if (ClientAddrOK(&sa.in, webServerAddrs))
                    break;

                close(socket);
            }  /* socket >= 0 */
        }  /* for(;;) */

        if (ReleaseLock(listen_sock))
            return (-1);

        if (sa.in.sin_family != AF_UNIX || is_af_unix_keeper(socket))
            break;

        close(socket);
    }  /* while(1) - lock */

    return (socket);
}
static BOOL Intercept(THREADID tid, DEBUGGING_EVENT eventType, CONTEXT *ctxt, VOID *)
{
    if (eventType == DEBUGGING_EVENT_BREAKPOINT)
    {
        // When the child thread reaches the breakpoint in Breakpoint(), wait for the main
        // thread to reach the One() function.  If the main thread is not there yet, squash the
        // breakpoint and move the PC back to the start of the Breakpoint() function.  This will
        // delay a while and then re-trigger the breakpoint.
        //
        ADDRINT pc = PIN_GetContextReg(ctxt, REG_INST_PTR);
        if (pc == BreakpointLocation && !AllowBreakpoint)
        {
            PIN_SetContextReg(ctxt, REG_INST_PTR, BreakpointFunction);
            GetLock(&Lock, 1);
            std::cout << "Squashing breakpoint at 0x" << std::hex << pc << " on thread " << std::dec << tid << std::endl;
            ReleaseLock(&Lock);
            return FALSE;
        }

        GetLock(&Lock, 1);
        std::cout << "Stopping at breakpoint at 0x" << std::hex << pc << " on thread " << std::dec << tid << std::endl;
        ReleaseLock(&Lock);
        return TRUE;
    }

    if (eventType == DEBUGGING_EVENT_ASYNC_BREAK)
    {
        // When the child thread triggers the breakpoint, we should be at the One() function.
        // Change the PC to the Two() function, which is the point of this test.  We want to
        // make sure Pin properly handles the change of PC in this case.
        //
        ADDRINT pc = PIN_GetContextReg(ctxt, REG_INST_PTR);
        if (pc == OneFunction)
        {
            PIN_SetContextReg(ctxt, REG_INST_PTR, TwoFunction);
            GetLock(&Lock, 1);
            std::cout << "Changing ASYNC BREAK PC to Two() on thread " << std::dec << tid << std::endl;
            ReleaseLock(&Lock);
            return TRUE;
        }

        // If the PC is not at the One() function, the child thread has probably hit some breakpoint
        // other than the one at Breakpoint().  (E.g. an internal breakpoint set by GDB.)  Don't
        // change the PC in such a case.
        //
        GetLock(&Lock, 1);
        std::cout << "ASYNC_BREAK at 0x" << std::hex << pc << " on thread " << std::dec << tid << std::endl;
        ReleaseLock(&Lock);
        return TRUE;
    }

    GetLock(&Lock, 1);
    std::cout << "FAILURE: Unexpected debugging event type" << std::endl;
    ReleaseLock(&Lock);
    std::exit(1);
}
예제 #9
0
	LPVOID GetProcAddr(HANDLE hProc)
	{
		AcquireLock();
		DWORD pid,addr,len;
		if (hProc==NtCurrentProcess()) pid=current_process_id;
		else
		{
			PROCESS_BASIC_INFORMATION info;
			NtQueryInformationProcess(hProc,ProcessBasicInformation,&info,sizeof(info),&len);
			pid=info.uUniqueProcessId;
		}
		pid>>=2;
		for (UINT_PTR i=0;i<count;i++)
		{
			if ((proc_record[i]&0xFFF)==pid)
			{
				addr=proc_record[i]&~0xFFF;
				ReleaseLock();
				return (LPVOID)addr;
			}
		}
		len=0x1000;
		NtAllocateVirtualMemory(hProc,(PVOID*)(proc_record+count),0,&len,
			MEM_COMMIT,PAGE_EXECUTE_READWRITE);
		DWORD base = proc_record[count];
		proc_record[count] |= pid;
		union
		{
			LPVOID buffer;
			DWORD b;
		};
		b = base;
		LPVOID fun_table[3];
		*(DWORD*)(normal_routine + ADDR0) += base;
		NtWriteVirtualMemory(hProc, buffer, normal_routine, 0x14, 0);
		*(DWORD*)(normal_routine + ADDR0) -= base;
		b += 0x14;
		fun_table[0] = NtTerminateThread;
		fun_table[1] = NtQueryVirtualMemory;
		fun_table[2] = MessageBoxW;
		NtWriteVirtualMemory(hProc, buffer, fun_table, 0xC, 0);
		b += 0xC;
		*(DWORD*)(except_routine + ADDR1) += base;
		*(DWORD*)(except_routine + ADDR2) += base;
		*(DWORD*)(except_routine + ADDR3) += base;
		NtWriteVirtualMemory(hProc, buffer, except_routine, 0xE0, 0);
		*(DWORD*)(except_routine + ADDR1) -= base;
		*(DWORD*)(except_routine + ADDR2) -= base;
		*(DWORD*)(except_routine + ADDR3) -= base;
		count++;
		ReleaseLock();
		return (LPVOID)base;
	}
예제 #10
0
int main()
{
	mv = CreateMV("mv1");
	mv2 = CreateMV("mv2");
	
	lck = CreateLock("lock1");
	lck2 = CreateLock("lock2");
	
	cv = CreateCV("cv1");

	for (loop =0; loop<500; loop++) 
	{
		AcquireLock(lck);
		SignalCV(lck,cv);

		AcquireLock(lck2);
		ret = GetMV(mv2);
		ReleaseLock(lck2);
		
		if (ret != 21)/*This will wait only if the other one isnt finished*/
			WaitCV(lck,cv);

		mvEdit = GetMV(mv);
		Print("Client 2: Monitor variable was read to be %d..",mvEdit,-1,-1);

		mvEdit+=7;
	
		
		ret=SetMV(mv,mvEdit);
		mvEdit = GetMV(lck);
	
		Print("Client 2: Monitor variable was set to be %d..",mvEdit,-1,-1);
		
		ReleaseLock(lck);	

		Print("Client 2: %d Iterations done..",loop,-1,-1);
	}
	
	AcquireLock(lck2);
	ret = SetMV(mv2,21);
	
	/*this monitor variable is set to 21 here to signify 
	*one of the processes is over and the other will not
	*wait for it to signal it
	*/
	ReleaseLock(lck2);
	
	AcquireLock(lck);
	SignalCV(lck,cv);
	ReleaseLock(lck);

}
예제 #11
0
void main()
{
    lck = CreateLock("lock1");
    cv = CreateCV("cv1");
    Print("Client 2: Created Lock is %d and CV is %d\n", lck, cv, -1);

    AcquireLock("lock1");


    Print("Client 2: About to signal Client 1\n", -1, -1, -1);

    SignalCV("lock1","cv1");

    Print("Client 2: About to go on wait...\n", -1, -1, -1);


    WaitCV("lock1","cv1");
    for (i=0; i<10; i++)
        Print("\n",-1,-1,-1);

    Print("Client 2: Now out of wait...\n", -1, -1, -1);
    ReleaseLock("lock1");

    Exit(0);
}
예제 #12
0
// Note that opening a file in a callback is only supported on Linux systems.
// See buffer-win.cpp for how to work around this issue on Windows.
//
// This routine is executed every time a thread is created.
VOID ThreadStart(THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v)
{
    GetLock(&lock, threadid+1);
    fprintf(out, "thread begin %d\n",threadid);
    fflush(out);
    ReleaseLock(&lock);
}
예제 #13
0
void t5_t3(){
    test=AcquireLock(LockIndex1);
    Write("3 acquired\n", sizeof("3 acquired\n"), 1);
    test=ReleaseLock(LockIndex1);
    Write("3 released\n", sizeof("3 released\n"), 1);
    Exit(0);
}
예제 #14
0
// This routine is executed each time malloc is called.
VOID BeforeMalloc( int size, THREADID threadid )
{
    GetLock(&lock, threadid+1);
    fprintf(out, "thread %d entered malloc(%d)\n", threadid, size);
    fflush(out);
    ReleaseLock(&lock);
}
예제 #15
0
/*!
 * Print out analysis results.
 * This function is called when the application exits.
 * @param[in]   code            exit code of the application
 * @param[in]   v               value specified by the tool in the 
 *                              PIN_AddFiniFunction function call
 */
VOID Fini(INT32 code, VOID *v)
{
    GetLock(&fileLock, 1);
    fclose(outfile);
    printf("outfile closed\n");
    ReleaseLock(&fileLock);
}
예제 #16
0
	void CheckProcessMemory()
	{
		UINT_PTR i,j,flag,addr;
		DWORD len;
		CLIENT_ID id;
		OBJECT_ATTRIBUTES oa={0};
		HANDLE hProc;
		BYTE buffer[8];
		AcquireLock();
		id.UniqueThread=0;
		oa.uLength=sizeof(oa);
		for (i=0;i<count;i++)
		{
			id.UniqueProcess=(proc_record[i]&0xFFF)<<2;
			addr=proc_record[i]&~0xFFF;
			flag=0;
			if (NT_SUCCESS(NtOpenProcess(&hProc,PROCESS_VM_OPERATION|PROCESS_VM_READ,&oa,&id)))	
			{
				if (NT_SUCCESS(NtReadVirtualMemory(hProc,(PVOID)addr,buffer,8,&len)))
					if (memcmp(buffer,normal_routine,4)==0) flag=1;
				NtClose(hProc);
			}
			if (flag==0)
			{
				for (j=i;j<count;j++) proc_record[j]=proc_record[j+1];
				count--; i--;
			}
		}
		ReleaseLock();
	}
예제 #17
0
//Track the first instance of our App.
//return TRUE on success, else FALSE
BOOL CInstanceChecker::TrackFirstInstanceRunning()
{
  //If a previous instance is running, just return prematurely
  if (PreviousInstanceRunning())
    return FALSE;

  //If this is the first instance then copy in our info into the shared memory

  //First create the MMF
  int nMMFSize = sizeof(CWindowInstance);
  g_sinstanceData.hInstanceData = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, nMMFSize, GetMMFFilename());
  if (g_sinstanceData.hInstanceData == NULL)
  {
    TRACE(_T("Failed to create the MMF even though this is the first instance, you might want to consider overriding GetMMFFilename()\n"));
    return FALSE;
  }

  //Open the MMF
  CWindowInstance* pInstanceData = static_cast<CWindowInstance*>(MapViewOfFile(g_sinstanceData.hInstanceData, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, nMMFSize));
  ASSERT(pInstanceData != NULL);   //Opening the MMF should work

  //Lock the data prior to updating it
  CSingleLock dataLock(&m_instanceDataMutex, TRUE);
  pInstanceData->hMainWnd = GetWindowToTrack();
  UnmapViewOfFile(pInstanceData);

  //Since this will be the last function that will be called 
  //when this is the first instance we can release the lock
  ReleaseLock();

  return TRUE;
}
예제 #18
0
파일: otudp.c 프로젝트: CNMAT/CNMAT-Externs
static Boolean BufferSanityCheck(OTUDP *x, int *freep, int *pendingp, int *outgoingp) {
	short oldLockout;
	int free, pending, outgoing, i;
	
	free = 100; // In case we fail to acquire lock
	
	// Mutual exclusion to prevent the lists from changing out from under me
	
	oldLockout = AcquireLock(x);
	free = CountPacketList(x->freeBuffers);
	pending = CountPacketList(x->pendingBuffers.first);
	outgoing = 0;
	ReleaseLock(x,oldLockout);

	if (freep != 0) *freep = free;
	if (pendingp != 0) *pendingp = pending;
	if (outgoingp != 0) *outgoingp = outgoing;

	if (free+pending+outgoing != x->nbufs) {
		error("otudp: BufferSanityCheck failed!  %d free + %d pending + %d outgoing = %d", 
			free, pending, free+pending+outgoing);
		return false;
	} else {
		return true;
	}

}
예제 #19
0
int main()
{

	lock = CreateLock("lock");
	lock2 = CreateLock("lock2");

	cv1 = CreateCV("cv1");
	cv2=CreateCV("cv2");

	AcquireLock("lock");
	
	SignalCV("lock","cv1");
	
	Print("Client 2 is going to wait...",-1,-1,-1);
	
	WaitCV("lock","cv2");

	for (i=0; i<9; i++)
		Print("\n",-1,-1,-1);
	
	Print("Client 2 is now out of wait...",-1,-1,-1);

	ReleaseLock("lock");

	Exit(0);

}
예제 #20
0
// This routine is executed every time a thread is destroyed.
VOID ThreadFini(THREADID threadid, const CONTEXT *ctxt, INT32 code, VOID *v)
{
    GetLock(&lock, threadid+1);
    fprintf(out, "thread end %d code %d\n",threadid, code);
    fflush(out);
    ReleaseLock(&lock);
}
예제 #21
0
///////////////////////////////////////////////////////////////////////////////
//  HandleIoctlPowerSet
//  Input:  pMemCard - SD memory card structure
//          pDevicePowerState - device power state
//  Output:
//  Return:
//  Notes:
///////////////////////////////////////////////////////////////////////////////
VOID HandleIoctlPowerSet(PSD_MEMCARD_INFO       pMemCard,
                         PCEDEVICE_POWER_STATE  pDevicePowerState)
{
    AcquireLock(pMemCard);

    DEBUGMSG(SDMEM_ZONE_POWER, (TEXT("SDMemory: IOCTL_POWER_SET %d \n"),*pDevicePowerState));

    if (*pDevicePowerState < pMemCard->PowerStateForIdle)  {
            // everything above the power state for idle is treated as D0
        *pDevicePowerState = D0;
        pMemCard->CurrentPowerState = D0;
            // disable low power operation
        pMemCard->EnableLowPower = FALSE;

    } else {
            // everything above the IDLE power state is set to IDLE
        *pDevicePowerState = pMemCard->PowerStateForIdle;
        pMemCard->CurrentPowerState = pMemCard->PowerStateForIdle;
            // enable low power operation
        pMemCard->EnableLowPower = TRUE;
            // wake up the idle thread to go into power idle polling
        SetEvent(pMemCard->hWakeUpIdleThread);
    }

    ReleaseLock(pMemCard);

}
예제 #22
0
VOID Error(std::string where, THREADID tid, UINT32 r, ADDRINT expect, ADDRINT val)
{
    GetLock(&Lock, 1);
    Out << "Mismatch " << where << ": tid=" << std::dec << tid << " (G" << r << ")" <<
        ", Expect " << std::hex << expect << ", Got " << std::hex << val << std::endl;
    ReleaseLock(&Lock);
}
// -----------------------------------------------------------------------------
// CPosLmLocalReadPartialLmOp::HandleError
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CPosLmLocalReadPartialLmOp::HandleError(
    TInt& aError)
    {
    iStatusFlag = aError;

    ReleaseLock();
    }
예제 #24
0
CHAR16 *
SEnvIGetStr (
  IN CHAR16           *Name,
  IN EFI_LIST_ENTRY   *Head
  )
/*++

Routine Description:

Arguments:

  Name - The variable name
  Head - The variable list
Returns:

--*/
{
  VARIABLE_ID *Var;
  CHAR16      *Value;

  AcquireLock (&SEnvLock);

  //
  // Walk through linked list to find corresponding Var
  //
  Value = NULL;
  Var   = SEnvFindVar (Head, Name);
  if (Var != NULL) {
    Value = Var->u.Str;
  }

  ReleaseLock (&SEnvLock);

  return Value;
}
예제 #25
0
파일: connection.c 프로젝트: blakawk/Aio4c
bool ConnectionNoMoreUsed (Connection* connection, ConnectionOwner owner) {
    bool result = true;
    int i = 0;

    TakeLock(connection->closedByLock);

    connection->closedBy[owner] = true;

    Log(AIO4C_LOG_LEVEL_DEBUG, "connection %s closed by: [reader:%u,worker:%u,writer:%u,acceptor:%u,client:%u]", connection->string,
            connection->closedBy[AIO4C_CONNECTION_OWNER_READER], connection->closedBy[AIO4C_CONNECTION_OWNER_WORKER],
            connection->closedBy[AIO4C_CONNECTION_OWNER_WRITER], connection->closedBy[AIO4C_CONNECTION_OWNER_ACCEPTOR],
            connection->closedBy[AIO4C_CONNECTION_OWNER_CLIENT]);

    for (i = 0; i < AIO4C_CONNECTION_OWNER_MAX && result; i++) {
        result = (result && connection->closedBy[i]);
    }

    if (result) {
        memset(connection->closedBy, 0, AIO4C_CONNECTION_OWNER_MAX * sizeof(bool));
    }

    ReleaseLock(connection->closedByLock);

    return result;
}
예제 #26
0
void t2_t1()
{

    /* checks acquire and release invalid input is handled properly.*/
    indexcheck1 = AcquireLock(5000);
    indexcheck2 = ReleaseLock(5000);
    indexcheck3 = AcquireLock(-1);
    indexcheck4= ReleaseLock(-1);

    /*this function is called the last among the functions that are used for the same test. print out the result and FORK next text function*/
    if(indexcheck1 == - 1 && indexcheck2 == -1 && indexcheck3 == -1 && indexcheck4 == -1) {
        Write("passed: acquire/releaselock validates input\n", sizeof("passed: acquire/releaselock validates input\n"), 1);
    }else{
        Write("failed: acquire/releaselock validates input\n", sizeof("failed: acquire/releaselock validates input\n"), 1);
    }
    Exit(0);
}
예제 #27
0
VOID ThreadStart(THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v)
{
    GetLock(&lock, threadid+1);
    numThreads++;
    ReleaseLock(&lock);
    
    ASSERT(numThreads <= MaxNumThreads, "Maximum number of threads exceeded\n");
}
예제 #28
0
파일: tc.c 프로젝트: achinksinghal/CSCI_402
/*
 * finding total number of customer in particular queue 
 * */
int getTotalCustCount(int debugId, mtQueue *queue)
{
	int count;
	AcquireLock(queueLock[queue->queueType][queue->queueId]);
	count=getMv(&queue->numCust);
	ReleaseLock(queueLock[queue->queueType][queue->queueId]);
	return count ;
}
예제 #29
0
파일: tc.c 프로젝트: achinksinghal/CSCI_402
/*
 * obtain current state of customer - 
 * We acquire a lock before seeing it 
 * and release lock once we are done
 * */
int getCustState(int debugId, int custId, int grpId)
{
	int state;
	AcquireLock(custLock[grpId][custId]); 
	state = getMv(&mtCb.custGrp[grpId].cust[custId].state);
	ReleaseLock(custLock[grpId][custId]); 
	return state;
}
예제 #30
0
VOID ThreadBegin(UINT32 threadid, VOID * sp, int flags, VOID *v)
{
    GetLock(&lock, threadid+1);
    numThreads++;
    ReleaseLock(&lock);
    
    ASSERT(numThreads <= MaxNumThreads, "Maximum number of threads exceeded\n");
}