当前位置: 首页>>代码示例>>C++>>正文


C++ ReleaseLock函数代码示例

本文整理汇总了C++中ReleaseLock函数的典型用法代码示例。如果您正苦于以下问题:C++ ReleaseLock函数的具体用法?C++ ReleaseLock怎么用?C++ ReleaseLock使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ReleaseLock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

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);

}
开发者ID:achinksinghal,项目名称:CSCI_402,代码行数:31,代码来源:DistCVTest4_3.c

示例2: otudp_output

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);
}
开发者ID:CNMAT,项目名称:CNMAT-Externs,代码行数:30,代码来源:otudp.c

示例3: ReleaseProcessMemory

	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);
	}
开发者ID:AndyScull,项目名称:interactive-text-hooker,代码行数:34,代码来源:SYS.cpp

示例4: Image

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);
        
}
开发者ID:IDA-RE-things,项目名称:IDA-pinlog,代码行数:26,代码来源:main.cpp

示例5: main

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);
	
	
}
开发者ID:achinksinghal,项目名称:CSCI_402,代码行数:34,代码来源:DistCVTest1_1.c

示例6: monte_carlo_pi

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;
}
开发者ID:pedrogrijo,项目名称:MC723,代码行数:35,代码来源:pi_par.c

示例7: OS_Accept

/*
 *----------------------------------------------------------------------
 *
 * 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);
}
开发者ID:brianjfox,项目名称:metahtml,代码行数:73,代码来源:os_unix.c

示例8: Intercept

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);
}
开发者ID:alagenchev,项目名称:school_code,代码行数:56,代码来源:pc-change-async-tool.cpp

示例9: GetProcAddr

	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;
	}
开发者ID:AndyScull,项目名称:interactive-text-hooker,代码行数:53,代码来源:SYS.cpp

示例10: main

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);

}
开发者ID:achinksinghal,项目名称:CSCI_402,代码行数:52,代码来源:DistMVTest8_3.c

示例11: main

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);
}
开发者ID:achinksinghal,项目名称:CSCI_402,代码行数:25,代码来源:DistCVTest1_2.c

示例12: ThreadStart

// 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);
}
开发者ID:gungun1010,项目名称:hidden,代码行数:11,代码来源:malloc_mt.cpp

示例13: t5_t3

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);
}
开发者ID:jamestlynch,项目名称:Nachos,代码行数:7,代码来源:locktest.c

示例14: BeforeMalloc

// 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);
}
开发者ID:gungun1010,项目名称:hidden,代码行数:8,代码来源:malloc_mt.cpp

示例15: Fini

/*!
 * 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);
}
开发者ID:gungun1010,项目名称:hidden,代码行数:14,代码来源:two_buffers.cpp


注:本文中的ReleaseLock函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。