示例#1
0
DWORD
CPullPin::ThreadProc(void)
{
    for (;;) {
	DWORD cmd = GetRequest();
	switch(cmd) {
	case TM_Exit:
	    Reply(S_OK);
	    return 0;

	case TM_Pause:
	    // we are paused already
	    Reply(S_OK);
	    break;

	case TM_Start:
	    Reply(S_OK);
	    Process();
	    break;
	}

	// at this point, there should be no outstanding requests on the
	// upstream filter.
	// We should force begin/endflush to ensure that this is true.
	// !!!Note that we may currently be inside a BeginFlush/EndFlush pair
	// on another thread, but the premature EndFlush will do no harm now
	// that we are idle.
	m_pReader->BeginFlush();
	CleanupCancelled();
	m_pReader->EndFlush();
    }
}
示例#2
0
//CAMThread Stuff
DWORD OggDemuxFilter::ThreadProc() 
{	
	while(true) 
    {
		DWORD locThreadCommand = GetRequest();
	
		switch(locThreadCommand) 
        {
			case THREAD_EXIT:
	
				Reply(S_OK);
                LOG(logDEBUG) << __FUNCTIONW__ << " THREAD IS EXITING";
				return S_OK;

			case THREAD_RUN:
	
				Reply(S_OK);
				DataProcessLoop();
                LOG(logDEBUG) << __FUNCTIONW__ << " Data Process Loop has returned";
				break;

           case THREAD_SEEK:

               m_oggBuffer.clearData();
               SetCurrentReaderPos(GetRequestedSeekPos());
               Reply(S_OK);

               DataProcessLoop();
               LOG(logDEBUG) << __FUNCTIONW__ << " Seek request";
               break;
		}
	}

	return S_OK;
}
示例#3
0
文件: rps.c 项目: taylorstark/CS452
static
VOID
RpspServerHandleOnePlayerQuitting
    (
        IN INT quittingPlayer,
        IN INT otherPlayer
    )
{
    RPS_SERVER_REQUEST otherPlayerRequest;
    RPS_SERVER_RESPONSE otherPlayerResponse = PartnerQuitResponse;

    bwprintf(BWCOM2, "Server: Client %d is quitting \r\n", quittingPlayer);

    // Acknowledge quitting player, and inform other player
    Reply(quittingPlayer, NULL, 0);
    Reply(otherPlayer, &otherPlayerResponse, sizeof(otherPlayerResponse));

    // Wait for other player to quit
    Receive(&otherPlayer, &otherPlayerRequest, sizeof(otherPlayerRequest));
    ASSERT(QuitRequest == otherPlayerRequest.type);

    bwprintf(BWCOM2, "Server: Client %d is quitting \r\n", otherPlayer);

    // Acknowledge player 2 quitting
    Reply(otherPlayer, NULL, 0);
}
示例#4
0
void nameserv () {
  char msg[6];
  int tid;
  int ans;
  
  struct name reg[100];
  int num = 0;

  while (1) {
    DPRINT("(()) Nameserver begining of loop...\r\n");
    Receive (&tid, msg, 6);
    DPRINT("received from tid %d, message(0x%x) \'%s\'\r\n", tid, msg, msg);
    switch (msg[0]) {
      case 'w':
        ans = lookup ((msg+1), reg, num);
//	bwprintf (COM2, "Nameserv:lookup gave %d.\r\n", ans);
        Reply(tid, (char*)&ans, 4);
//	bwprintf (COM2, "Nameserv: Reply sucessfull.\r\n");
        break;
      case 'r':
        DPRINT("NAMES: registering %s to tid %d.\r\n", msg + 1, tid);
        strcpy (reg[num].name, msg + 1);
        reg[num++].tid  = tid;
	      Reply (tid, 0, 0);
//	bwprintf (COM2, "Nameserv: Reply sucessfull.\r\n");
        break;
      default: 
        Reply (tid, 0, 0);
        break;
    }
  }
}
DWORD  CAVISplitter::ThreadProc()
{
	m_threadid = GetCurrentThreadId();
	while (1) 
	{
		DWORD cmd = GetRequest();
		switch (cmd)
		{
		case tm_exit:
            stopPinsProcessingThreads();
			Reply(S_OK);
            return 0;

		case tm_pause:
			// we are paused already
            stopPinsProcessingThreads();
			Reply(S_OK);
            break;

		case tm_start:
			startPinsProcessingThreads();
            Reply(S_OK);
            break;
		}

	}
	return 0;
}
DWORD CWavPackDSSplitterInputPin::ThreadProc()
{
    Command com; 
    
    DebugLog("===> Entering CWavPackDSSplitterInputPin::ThreadProc... 0x%08X", GetCurrentThreadId());

    do 
    { 
        DebugLog("===> ThreadProc waiting command... 0x%08X", GetCurrentThreadId());
        com = (Command)GetRequest();
        switch (com) 
        { 
        case CMD_EXIT:
            DebugLog("===> ThreadProc CMD_EXIT 0x%08X", GetCurrentThreadId());
            Reply(NOERROR); 
            break; 
            
        case CMD_STOP: 
            DebugLog("===> ThreadProc CMD_STOP 0x%08X", GetCurrentThreadId());
            Reply(NOERROR); 
            break; 
            
        case CMD_RUN:
            DebugLog("===> ThreadProc CMD_RUN 0x%08X", GetCurrentThreadId());
            DebugLog("===> Entering DoProcessingLoop... 0x%08X", GetCurrentThreadId());
            DoProcessingLoop(); 
            DebugLog("<=== Leaving DoProcessingLoop 0x%08X", GetCurrentThreadId());
            break; 
        } 
    } while (com != CMD_EXIT);

    DebugLog("<=== Leaving CWavPackDSSplitterInputPin::ThreadProc 0x%08X", GetCurrentThreadId());
    
    return NOERROR; 
}
示例#7
0
文件: tptestmaster.c 项目: stein1/bbk
void SendServerList( int Sock )
{
  FILE *fp;
  char buf[250], writebuf[256];
  int len;
  fp = fopen(FileName, "r");
  if (fp == NULL) {
    Reply(Sock, 410, "No service right now. Please try again later");
    return;
  }
  while (!feof(fp)) {
    memset(buf, 0, 250);
    fgets(buf, 249, fp);
    stripcrlf(buf);
    if (buf[0] == '#')
      continue;
    if (strlen(buf) < 10)
      continue;
    sprintf(writebuf, "210-%s\r\n", buf);
    len = strlen(writebuf);
    if (len < 3)
      continue;
    if (write( Sock, writebuf, len ) != len)
    {
      syslog(LOG_ERR, "write() failed");
      return;
    }
  }
  Reply(Sock, 210, " ");
  sleep(1);
}
示例#8
0
文件: chess.cpp 项目: cycad/opencore
void
CmdChessHelp(CORE_DATA *cd)
{
	Reply("This is a Player-vs-Player Chess bot");
	Reply("It is in testing and doesn't support the following:");
	Reply("- En Passant");
	Reply("- Underpromotions");
}
示例#9
0
static
VOID
SwitchpTask()
{
    SWITCH_DIRECTION directions[NUM_SWITCHES];

    VERIFY(SUCCESSFUL(RegisterAs(SWITCH_SERVER_NAME)));

    IO_DEVICE com1;
    VERIFY(SUCCESSFUL(Open(UartDevice, ChannelCom1, &com1)));

    for (UINT i = 0; i < NUM_SWITCHES; i++)
    {
        UCHAR sw = SwitchpFromIndex(i);

        VERIFY(SUCCESSFUL(SwitchpDirection(&com1, sw, SwitchCurved)));

        directions[i] = SwitchCurved;

        ShowSwitchDirection(i, sw, SwitchCurved);
    }

    VERIFY(SUCCESSFUL(SwitchpDisableSolenoid(&com1)));

    while (1)
    {
        INT senderId;
        SWITCH_REQUEST request;

        VERIFY(SUCCESSFUL(Receive(&senderId, &request, sizeof(request))));

        switch(request.type)
        {
            case SetDirectionRequest:
            {
                VERIFY(SUCCESSFUL(SwitchpDirection(&com1, request.sw, request.direction)));
                VERIFY(SUCCESSFUL(SwitchpDisableSolenoid(&com1)));

                UINT switchIndex = SwitchpToIndex(request.sw);
                directions[switchIndex] = request.direction;

                VERIFY(SUCCESSFUL(Reply(senderId, NULL, 0)));

                ShowSwitchDirection(switchIndex, request.sw, request.direction);

                break;
            }

            case GetDirectionRequest:
            {
                UINT switchIndex = SwitchpToIndex(request.sw);
                SWITCH_DIRECTION direction = directions[switchIndex];
                VERIFY(SUCCESSFUL(Reply(senderId, &direction, sizeof(direction))));
                break;
            }
        }
    }
}
示例#10
0
DWORD CAsyncUrlReader::ThreadProc()
{
    AfxSocketInit(nullptr);

    DWORD cmd = GetRequest();
    if (cmd != CMD_INIT) {
        Reply((DWORD)E_FAIL);
        return (DWORD) - 1;
    }

    try {
        CInternetSession is;
        CAutoPtr<CStdioFile> fin(is.OpenURL(m_url, 1, INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_CACHE_WRITE));

        TCHAR path[MAX_PATH], fn[MAX_PATH];
        CFile fout;
        if (GetTempPath(MAX_PATH, path) && GetTempFileName(path, _T("mpc_http"), 0, fn)
                && fout.Open(fn, modeCreate | modeWrite | shareDenyWrite | typeBinary)) {
            m_fn = fn;

            char buff[1024];
            int len = fin->Read(buff, sizeof(buff));
            if (len > 0) {
                fout.Write(buff, len);
            }

            Reply(S_OK);

            while (!CheckRequest(&cmd)) {
                int len2 = fin->Read(buff, sizeof(buff));
                if (len2 > 0) {
                    fout.Write(buff, len2);
                }
            }
        } else {
            Reply((DWORD)E_FAIL);
        }

        fin->Close(); // must close it because the destructor doesn't seem to do it and we will get an exception when "is" is destroying
    } catch (CInternetException* ie) {
        ie->Delete();
        Reply((DWORD)E_FAIL);
    }

    //

    cmd = GetRequest();
    ASSERT(cmd == CMD_EXIT);
    Reply(S_OK);

    //

    m_hThread = nullptr;

    return S_OK;
}
示例#11
0
文件: chess.cpp 项目: cycad/opencore
void
CmdMove(CORE_DATA *cd)
{
	USER_DATA *ud = UD(cd);

	// the game hasnt started
	if (ud->in_progress == false) {
		Reply("The game has not yet begun");
		return;
	}

	// check for correct arg count
	if (cd->cmd_argc != 2) {
		ReplyFmt("Usage: !move Coord,Coord");
		ReplyFmt("Example: !move e2,e4");
		return;
	}

	// make sure the player is playing
	if (IsPlaying(ud, cd->cmd_name) == false) {
		Reply("You are not playing in this match");
		return;
	}

	// replies to players in-game are via arena

	// check whos turn it is
	if (GetColor(ud, cd->cmd_name) != ud->to_move) {
		ArenaMessage("It is not your move");
		return;
	}
				
	// parse argument
	char xstr[3];
	char ystr[3];
	DelimArgs(xstr, 3, cd->cmd_argv[1], 0, ',', false);
	DelimArgs(ystr, 3, cd->cmd_argv[1], 1, ',', false);

	int x1, y1, x2, y2;
	if (ParseCoords(xstr, &x1, &y1) == true &&
	    ParseCoords(ystr, &x2, &y2) == true) {
		
		char *err = TryMove(ud, ud->to_move, x1, y1, x2, y2);
		if (err == NULL && ud->in_progress == true) {
			// successful moves are announced in TryMove()
			ud->to_move = GetOppositeColor(ud->to_move);
			LvzToMove(ud->to_move, NULL);
			ArenaMessageFmt("%s (%s) to Move",
			    GetPlayerName(ud, ud->to_move), GetColorText(ud->to_move));
		} else if (ud->in_progress == true) {
			ArenaMessageFmt("Couldn't move: %s", err);
		}
	} else {
		ArenaMessageFmt("Invalid coordinates");
	}
}
示例#12
0
DWORD CBDReaderFilter::ThreadProc()
{
  SetThreadName(-1, "BDReader_WORKER");

  m_bFlushing = false;
  m_eEndFlush.Set();

  for (DWORD cmd = (DWORD)-1; ; cmd = GetRequest())
  {
    if (cmd == CMD_EXIT)
    {
      m_hThread = NULL;
      Reply(S_OK);
      return 0;
    }

    SetThreadPriority(m_hThread, THREAD_PRIORITY_NORMAL);

    m_rtStart = m_rtNewStart;
    m_rtStop = m_rtNewStop;

    if (cmd == CMD_SEEK)
      Seek(m_rtStart);

    if (cmd != (DWORD)-1)
      Reply(S_OK);

    // Wait for the end of any flush
    m_eEndFlush.Wait();

    if (cmd == CMD_SEEK)
    {
      m_pVideoPin->DeliverNewSegment(m_rtStart, m_rtStop, m_dRate);
      m_pAudioPin->DeliverNewSegment(m_rtStart, m_rtStop, m_dRate);
      m_pSubtitlePin->DeliverNewSegment(m_rtStart, m_rtStop, m_dRate);

      m_eEndNewSegment.Set();
    }

    while (!CheckRequest(&cmd)) 
      Sleep(5); // TODO remove polling or maybe start to use the worker thread for pre-caching data

    // If we didnt exit by request, deliver end-of-stream
    if (!CheckRequest(&cmd)) 
    {
      m_pAudioPin->EndOfStream();
      m_pVideoPin->EndOfStream();
      m_pSubtitlePin->EndOfStream();
    }
  }
  ASSERT(0); // we should only exit via CMD_EXIT

  m_hThread = NULL;
  return 0;
}
示例#13
0
HRESULT CPushAudioPin::DoBufferProcessingLoop(void) {
	Command com;
	OnThreadStartPlay();
	do {
		while (!CheckRequest(&com)) {
			HRESULT hr;
			CAutoLock lock(&m_cSharedState);

			if( WaitForSingleObject( this->buffLockEvent, 500 ) == WAIT_OBJECT_0 ){
				if( this->buffData.size() != 0 ){
					if( this->buffLockEvent != NULL ){
						SetEvent(this->buffLockEvent);
					}
					IMediaSample *pSample;
					hr = GetDeliveryBuffer(&pSample,NULL,NULL,0);
					if (FAILED(hr)) {
						Sleep(1);
						continue;
					}
					hr = FillBuffer(pSample);
					if (hr == S_OK) {
						hr = Deliver(pSample);
						pSample->Release();

						if(hr != S_OK)
						{
							return S_OK;
						}
					} else if (hr == S_FALSE) {
						pSample->Release();
						DeliverEndOfStream();
						return S_OK;
					} else {
						pSample->Release();
						DeliverEndOfStream();
						m_pFilter->NotifyEvent(EC_ERRORABORT, hr, 0);
						return hr;
					}
				}else{
					if( this->buffLockEvent != NULL ){
						SetEvent(this->buffLockEvent);
					}
					Sleep(10);
				}
			}
		}
		// For all commands sent to us there must be a Reply call!
		if (com == CMD_RUN || com == CMD_PAUSE) {
			Reply(NOERROR);
		} else if (com != CMD_STOP) {
			Reply((DWORD) E_UNEXPECTED);
		}
	} while (com != CMD_STOP);
	return S_FALSE;
}
示例#14
0
void Affiche_TAGs(int fd)
{
	Reply(fd,"- %d Tags\n",TAGs.Count);
	if (TAGs.Count<=0) return;
	ELEMENT *elt=GetFirst(&TAGs);
	if (elt!=NULL) do
	{
		TAG *tag=elt->Data;
		Reply(fd,"Tag %p : %s \t\t(Plc %p)\n",tag,tag->TagName,tag->Plc);
	} while ((elt=GetNext(&TAGs,elt))!=NULL);
}
示例#15
0
void Affiche_Clients(int fd)
{
	Reply(fd,"- %d Clients\n",CLIENTs.Count);
	if (CLIENTs.Count<=0) return;
	ELEMENT *elt=GetFirst(&CLIENTs);
	if (elt!=NULL) do
	{
		CLIENT *client=elt->Data;
		Reply(fd,"Clients %p : %d\n",client,client->FD);
	} while ((elt=GetNext(&CLIENTs,elt))!=NULL);
}
示例#16
0
void Affiche_Sessions(int fd)
{
	Reply(fd,"- %d Sessions\n",SESSIONs.Count);
	if (SESSIONs.Count<=0) return;
	ELEMENT *elt=GetFirst(&SESSIONs);
	if (elt!=NULL) do
	{
		Eip_Session *ses=elt->Data;
		Reply(fd,"Sessions %p : %d \t\t %d ref\n",ses,ses->sock,ses->References);
	} while ((elt=GetNext(&SESSIONs,elt))!=NULL);
}
示例#17
0
void Affiche_PLCs(int fd)
{
	Reply(fd,"- %d Plcs\n",PLCs.Count);
	if (PLCs.Count<=0) return;
	ELEMENT *elt=GetFirst(&PLCs);
	if (elt!=NULL) do
	{
		PLC *plc=elt->Data;
		Reply(fd,"Plc %p : %s \t\t(%p/%p) %d ref\n",plc,plc->PlcName,plc->Session,plc->Connection,plc->References);
	} while ((elt=GetNext(&PLCs,elt))!=NULL);
}
示例#18
0
void Affiche_Connections(int fd)
{
	Reply(fd,"- %d Connections\n",CONNECTIONs.Count);
	if (CONNECTIONs.Count<=0) return;
	ELEMENT *elt=GetFirst(&CONNECTIONs);
	if (elt!=NULL) do
	{
		Eip_Connection *conn=elt->Data;
		Reply(fd,"Connection %p : %d \t\t %d ref\n",conn,conn->ConnectionSerialNumber,conn->References);
	} while ((elt=GetNext(&CONNECTIONs,elt))!=NULL);
}
示例#19
0
void first_task_code () {
    // creates other tasks
    volatile int taskid;
    int tid = 0;
    int priority = 0;
    struct dr rec;

    taskid = Create(PR_NS, NScode);
    kprintf("NS has been Created: %d\n\r", taskid);

    taskid = Create(PR_NOTIFIER, notifier_code);
    kprintf("NOTIFIER has been Created: %d\n\r", taskid);

    taskid = Create(PR_CS, clock_server_code);
    kprintf("CS has been Created: %d\n\r", taskid);

    for (priority = 3; priority < 7; priority++) {
        taskid = Create(priority, client_code);
        kprintf("Created: %d\n\r", taskid);
    }

    taskid = Create(PR_LOWEST, idle_task_code);
    kprintf("Idle Task has been Created: %d\n\r", taskid);



    Receive(&tid, &rec, sizeof(struct dr));
    rec.ticks = 10;
    rec.iters = 20;
    Reply(tid, &rec, sizeof(struct dr));

    Receive(&tid, &rec, sizeof(struct dr));
    rec.ticks = 23;
    rec.iters = 9;
    Reply(tid, &rec, sizeof(struct dr));

    Receive(&tid, &rec, sizeof(struct dr));
    rec.ticks = 33;
    rec.iters = 6;
    Reply(tid, &rec, sizeof(struct dr));

    Receive(&tid, &rec, sizeof(struct dr));
    rec.ticks = 71;
    rec.iters = 3;
    Reply(tid, &rec, sizeof(struct dr));



    kprintf("First: exiting...\n\r");

    Exit();
    kprintf ("Unexpected return from Exit() at first_task_code\n\r");
}
示例#20
0
文件: rps.c 项目: taylorstark/CS452
static
VOID
RpsServerHandleBothPlayersQuitting
    (
        IN INT player1,
        IN INT player2
    )
{
    bwprintf(BWCOM2, "Server: Client %d is quitting \r\n", player1);
    bwprintf(BWCOM2, "Server: Client %d is quitting \r\n", player2);

    Reply(player1, NULL, 0);
    Reply(player2, NULL, 0);
}
示例#21
0
void switch_server() {
    server_tid = MyTid();

    switches_init();

    // Find the location server.
    tid_t location_server_tid = -2;
    do {
        location_server_tid = WhoIs("LocationServer");
        dlog("Location Server Tid %d\n", location_server_tid);
    } while (location_server_tid < 0);

    tid_t tid;
    SwitchServerMessage msg, reply;
    while (1) {
        Receive(&tid, (char *) &msg, sizeof(msg));
        switch (msg.type) {
        case SET_SWITCH:
            reply.type = SET_SWITCH_RESPONSE;
            Reply(tid, (char *) &reply, sizeof(reply));
            switch_set(msg.switch_no, msg.direction, location_server_tid);
            break;
        default:
            break;
        }
    }
}
示例#22
0
void receiver(void) {
	int sender_tid = -1;
	char byte4[4];
	int  byte64[64];
	int ret;
	ret = Receive(&sender_tid, byte64, 64);
	Reply(sender_tid, (void*)byte64, 64);
	ret = Receive(&sender_tid, byte4, 4);
	Reply(sender_tid, byte4, 4);
	
	ret = Receive(&sender_tid, byte64, 64);
	Reply(sender_tid, (void*)byte64, 64);
	ret = Receive(&sender_tid, byte64, 64);
	Reply(sender_tid, (void*)byte64, 64);
	Exit();
}
示例#23
0
void routeFinder( ) {
	track_node track[TRACK_MAX];
	init_tracka(track);

	RegisterAs( "route" );

	// int printer = MyParentTid();
	ComReqStruct reply;
	int sender;

	FOREVER {
		Receive( &sender, (char *)&reply, sizeof(ComReqStruct) );

		int src  = reply.data1;	// No offset right now
		int dest = reply.data2;

		// Begin finding the shortest path from the src to the dest
		Path shortest;
		route( track, &shortest, src, dest );

		ComReqStruct fus, roh;
	fus.type = UPDATE_STAT;
	fus.data1 = (int *)&shortest;
	Send( MyParentTid(), (char *)&fus, sizeof(ComReqStruct), (char *)&roh, sizeof(ComReqStruct) );

		Reply( sender, (char *)&shortest, sizeof(Path) );
	}
}
示例#24
0
HRESULT CWavPackSplitterFilterInputPin::DoProcessingLoop(void)
{
	DWORD cmd;
	HRESULT hr;

	Reply(NOERROR);
	m_bAbort = FALSE;

	m_pParentFilter->m_pOutputPin->DeliverNewSegment(0,
	m_pParentFilter->m_rtStop - m_pParentFilter->m_rtStart,
	m_pParentFilter->m_dRateSeeking);

	do
	{
		if (m_pIACBW->StreamPos >= m_pIACBW->StreamLen || wavpack_parser_eof(m_pWavPackParser)) {
			// EOF
			m_pParentFilter->m_pOutputPin->DeliverEndOfStream();
			// TODO : check if we need to stop the thread
			return NOERROR;
		}

		hr = DeliverOneFrame(m_pWavPackParser);
		if (FAILED(hr)) {
			return hr;
		}
	} while (!CheckRequest(&cmd) && !m_bAbort);

	return NOERROR;
}
示例#25
0
void sensor_server() {
    struct SensorService service;    
    sensorservice_initialize(&service);

    RegisterAs("SensorServer");

    // Create the thing sending us sensor messages.
    Create(HIGH, sensor_notifier);

    tid_t stream = CreateStream("SensorServerStream");

    int tid;
    SensorServerMessage msg, rply;
    for(;;) {
        Receive(&tid, (char *) &msg, sizeof(msg));

        switch(msg.type) {
            case SENSOR_EVENT_REQUEST:
                rply.type = SENSOR_EVENT_RESPONSE;
                Reply(tid, (char *) &rply, sizeof(rply));

                sensorservice_process_data(&service, msg.data);

                publish(&service, stream);
                break;
            default:
                ulog("Invalid SensorServer Request");
        }
    }

    Exit();
}
示例#26
0
文件: clock.c 项目: RobertElder/CS452
void ClockServer_HandleDelayRequest(ClockServer * server, int source_tid, ClockMessage * receive_msg, short absolute) {
	//robprintfbusy((const unsigned char *)"ClockServer TID=%d: Handle Delay Request from %d with value %d\n", server->tid, source_tid, receive_msg->num);
	
	if (!absolute) {
		receive_msg->num += server->ticks;
	}
	
	if (receive_msg->num <= server->ticks) {
		robprintfbusy((const unsigned char *)
		"\033[1;33mClockServer: WARNING delay value in the past from tid=%d! "
		"Got=%d, now=%d\033[0m\n", source_tid, receive_msg->num, server->ticks);
	
		ClockMessage * reply_message = (ClockMessage *) server->reply_buffer;
		
		if (absolute) {
			reply_message->message_type = MESSAGE_TYPE_DELAY_UNTIL_REPLY;
		} else {
			reply_message->message_type = MESSAGE_TYPE_DELAY_REPLY;
		}
	
		Reply(source_tid, server->reply_buffer, MESSAGE_SIZE);
	} else {
		server->tid_to_delay_until[source_tid] = receive_msg->num;
	}
}
示例#27
0
文件: clock.c 项目: RobertElder/CS452
void ClockServer_UnblockDelayedTasks(ClockServer * server) {
	int tid = 0;
	int count = 0;
	
	while (1) {
		tid = ClockServer_GetNextTask(server, tid);
		
		if (tid == 0) {
			break;
		}
		
		server->tid_to_delay_until[tid] = 0;
		
		ClockMessage * reply_message = (ClockMessage *) server->reply_buffer;
		reply_message->message_type = MESSAGE_TYPE_DELAY_REPLY;
		
		//robprintfbusy((const unsigned char *)"ClockServer TID=%d: unblocking %d\n", server->tid, tid);
	
		Reply(tid, server->reply_buffer, MESSAGE_SIZE);
		
		count++;
		
		assert(count <= MAX_TASKS + 1, "ClockServer_UnblockDelayedTasks running for too long");
	}
	
}
示例#28
0
文件: clock.c 项目: RobertElder/CS452
void ClockServer_HandleNotifier(ClockServer * server, int source_tid, NotifyMessage * receive_msg) {
	//robprintfbusy((const unsigned char *)"ClockServer TID=%d: Handle Notifer from %d\n", server->tid, source_tid);
	
	assert(receive_msg->event_id == CLOCK_TICK_EVENT, "ClockServer didn't get a clock tick event id");
	
	ClockMessage * reply_message = (ClockMessage *) server->reply_buffer;
	
	if (server->shutdown) {
		reply_message->message_type = MESSAGE_TYPE_SHUTDOWN;
		server->running = 0;
	} else {
		reply_message->message_type = MESSAGE_TYPE_ACK;
	}
	
	// Debugging code
	int now = *TIMER4_VAL_LOW;
	int diff = (now - server->last_timer_value) / 983.0 * 1000.0;
	server->last_timer_value = now;

	Reply(source_tid, server->reply_buffer, MESSAGE_SIZE);
	
	// Debugging code
	if (diff > TICK_SIZE * 1000 + 1000) {
		robprintfbusy((const unsigned char *) "\033[1;31mSLOW! %dus\033[0m\n", diff);
	}
	
	server->ticks += 1;
}
示例#29
0
void  CDdmCMB::ReqIopControl2 (void *pvReqMsg, STATUS sStatus,
                               const CmbPacket *pReply)
{

MsgCmbIopControl   * pReq  =  (MsgCmbIopControl *) pvReqMsg;
IopState             eNewState;


   assert (pReq != NULL);

   if (sStatus != CTS_SUCCESS)
      {
      //  whoops, request failed.  Stop right here.
      Reply (pReq, sStatus);
      return;
      }

   //  got an update, so let's refresh our status table.
   CmbStateToIopStatus (pReply, eNewState);

   //  roll new state into IOP Status table, and then reply to requestor
   SetIopPtsStateAndReply (pReq->m_Payload.eTargetSlot, eNewState, pReq);

   return;

}  /* end of CDdmCMB::ReqIopControl2 */
示例#30
0
// .Initialize -- Process Initialize -------------------------------------------------------DdmNull-
//
ERC DdmNull::Initialize(Message *pArgMsg) {
	TRACE_PROC(DdmNull::Initialize);
	
	Reply(pArgMsg,OK);	// Initialize Complete
			
	return OK;
}