Пример #1
0
static void 
cmdThread(void *arg)
{
    struct sockaddr_in serv_addr;
    //    struct sockaddr_in remote_addr;
    int sock;
    int ret;

    dbgprintf( "IOP cmd: Server Thread Started.\n" );

    sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if (sock < 0)
    {
        dbgprintf( "IOP cmd: Socket error %d\n", sock);
        ExitDeleteThread();
    }

    memset((void *)&serv_addr, 0, sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
    serv_addr.sin_port = htons(PKO_CMD_PORT);
   
    ret = bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
    if (ret < 0) {
        dbgprintf("IOP cmd: Udp bind error (%d)\n", sock);
        ExitDeleteThread();
    }

    // Do tha thing
    dbgprintf("IOP cmd: Listening\n");

    cmdListener(sock);

    ExitDeleteThread();
}
Пример #2
0
// From PS2DEV.ORG - Thread dispatcher
static void ioThreadDispatcher ( void* apParam ) {
	while ( ! gIOTerminate ) { 
		SleepThread (); 
	}  /* end while */ 
	
	ExitDeleteThread();
}  /* end dispatcher */ 
Пример #3
0
/*! \brief naplink compatbile RPC handler thread.
 *  \ingroup fakehost 
 *
 *  \param  arg Startup parameters.
 */
static void napThread(void *arg)
{
    int pid;

    SifInitRpc(0);
    pid = GetThreadId();
    SifSetRpcQueue(&queue, pid);
    SifRegisterRpc(&server, RPC_NPM_USER, naplinkRpcHandler,
                   rpc_buffer, 0, 0, &queue);
    SifRpcLoop(&queue);  // Never exits
    ExitDeleteThread();
}
Пример #4
0
static void ioWorkerThread(void) {
	while (!gIOTerminate) {
		SleepThread();

		// no processing when io is blocked
		if (isIOBlocked)
			continue;
			
		// if term requested exit immediately from the loop
		if (gIOTerminate)
			break;
		
		// do we have a request in the queue?
		while (gReqList) {
			WaitSema(gProcSemaId);
			
			struct io_request_t* req = gReqList;
			ioProcessRequest(req);

			// lock the queue tip as well now
			WaitSema(gEndSemaId);
			
			// can't be sure if the request was
			gReqList = req->next;
			free(req);
						
			if (!gReqList)
				gReqEnd = NULL;

			SignalSema(gProcSemaId);
			SignalSema(gEndSemaId);
		}
	}
	
	// delete the pending requests
	while (gReqList) {
		struct io_request_t* req = gReqList;
		gReqList = gReqList->next;
		free(req); // TODO: Leak over here - we need a propper flag to free/not the user data
	}
	
	// delete the semaphores
	DeleteSema(gProcSemaId);
	DeleteSema(gEndSemaId);
	
	isIORunning = 0;

	ExitDeleteThread();
}
Пример #5
0
static void ioWorkerThread(void *arg) {
	while (!gIOTerminate) {
		SleepThread();

		// if term requested exit immediately from the loop
		if (gIOTerminate)
			break;

		// do we have a request in the queue?
		WaitSema(gProcSemaId);
		while (gReqList) {
			// if term requested exit immediately from the loop
			if (gIOTerminate)
				break;

			struct io_request_t* req = gReqList;
			ioProcessRequest(req);

			// lock the queue tip as well now
			WaitSema(gEndSemaId);

			// can't be sure if the request was
			gReqList = req->next;
			free(req);

			if (!gReqList)
				gReqEnd = NULL;

			SignalSema(gEndSemaId);
		}
		SignalSema(gProcSemaId);
	}

	// delete the pending requests
	while (gReqList) {
		struct io_request_t* req = gReqList;
		gReqList = gReqList->next;
		free(req);
	}

	// delete the semaphores
	DeleteSema(gProcSemaId);
	DeleteSema(gEndSemaId);

	isIORunning = 0;

	ExitDeleteThread();
}
Пример #6
0
static void
InitTimer(void)
{
	iop_thread_t	Thread={TH_C,0,TimerThread,0x800,0x22};
	int				iTimerThreadID=CreateThread(&Thread);

	if (iTimerThreadID<0)
	{
		printf("InitTimer: Fatal error - Failed to create tcpip timer-thread!\n");
		ExitDeleteThread();
	}

	//Start timer-thread

	StartThread(iTimerThreadID,NULL);
}
Пример #7
0
void main_thread(void *unused) {
    int i = 0;

    DelayThread(1000*1000);

    printf("IOP: about to trap!\n");
    trigger();
    printf("IOP: back from trap!\n");
    while(1) {
        printf("IOP: still running %d\n", i++);
        DelayThread(2000*1000);
	if (i == 10)
	    break;
    }
    ExitDeleteThread();
}