コード例 #1
0
ファイル: periodictasks.c プロジェクト: uwevil/ASTRE
void *runPeriodicTask (void *t){
  TaskInfo           s;      // self reference
  Time               c = 0;  // completion time
  Time               d = 0;  // deadline

  s = periodicTaskTable[*(int *)t];

  while (systemNotCompleted()){

    // Compute the deadline or the next activation
    d=nextActivation(s.period);

    putHeader (s.name);
    putString ("activated");
    newLine();

    // Simulate the execution of this task using
    // computeDuringTimeSpan. Provide the name of the task, its worst
    // case execution time, and the period of the task. ATTENTION :
    // the period parameter in computeDuringTimeSPan is used to
    // compute the execution priority. It returns the completion time
    // that should be used to check whether the task missed its
    // deadline. Use variable c to save this value. See tasks.h.


    //    NYI("compute task for its computation time");
    //********************************************************
      c = computeDuringTimeSpan(s.name, s.computation, s.period);
    
    //    NYI("save the completion time in variable c for later use");
    //********************************************************
    // c = timeAfterTimeSpan(s.computation);
    
    putHeader (s.name);
    putString ("completed");
    newLine();

    // Check that the completion time did not occur after the deadline
    if (d < c) {
      putHeader (s.name);
      putString ("OVERRUN ");
      putTime   (d);
      putString (" < ");
      putTime   (c);
      newLine();
      break;
    };

    // Wait for the next activation. In other words, wait for the deadline.
    // NYI("wait for the next activation");
    //**********************************************************
    delayUntil(d);

    
  }

  return NULL;
}
コード例 #2
0
int      
LogBuffer::overflow(int c)
{
   switch(c) {
      case EOF:
         // NOP
      break;
      case '\n':
/*         if (m_level != LOGLEVEL_DEBUG || m_debug)
            m_buf->overflow(c); */
         if (m_bufPos > 0)
            notify();
         // set the flag
         m_newline = true;
         m_level = LOGLEVEL_DEBUG;
         m_bufPos = 0;
         if (m_prefix != NULL) {
            strcpy(m_buffer, m_prefix);
            m_bufPos = strlen(m_buffer);
         }
      break;
      case '\0':
         // handle the next character as a magic one ?
         if (m_newline)
            m_magic = true;
      break;
      default:
         if (m_magic) {
            m_magic = false;
            if ('I' == c)
               m_level = LOGLEVEL_INFO;
            else if ('W' == c)
               m_level = LOGLEVEL_WARN;
            else if ('E' == c)
               m_level = LOGLEVEL_ERROR;
            else if ('F' == c)
               m_level = LOGLEVEL_FATAL;
         } else if (m_level != LOGLEVEL_DEBUG || m_debug) {
            // should we output the time and log level now?
            if (m_newline) {
               m_newline = false;
               if (putTime() == EOF)
                  return EOF;
               if (putLevel() == EOF)
                  return EOF;
            }
            // put it in our buffer
            if (m_bufPos < 32766)
               m_buffer[m_bufPos++] = (char)c;
         }
      break;
   }

   return 0;
}
コード例 #3
0
static void
gltrace_putMark(JNIEnv *jni, jclass klass, jstring jstr)
{
    uint64_t bgn = gethrtime();
    const char *str = (*jni)->GetStringUTFChars(jni, jstr, 0);
    putCmd(OPC_MARK);
    putString(str);
    (*jni)->ReleaseStringUTFChars(jni, jstr, str);
    uint64_t end = gethrtime();
    putTime(bgn, end);
}
コード例 #4
0
ファイル: tedstd.cpp プロジェクト: BackupTheBerlios/toped-svn
laydata::TEDfile::TEDfile(tdtdesign* design, std::string& filename) { //writing
   _design = design;_revision=0;_subrevision=6;
   if (NULL == (_file = fopen(filename.c_str(), "wb"))) {
      std::string news = "File \"";
      news += filename.c_str(); news += "\" can not be created";
      tell_log(console::MT_ERROR,news);
      return;
   }   
   putString(TED_LEADSTRING);
   putRevision();
   putTime();
   _design->write(this);
   fclose(_file);
}
コード例 #5
0
ファイル: note.cpp プロジェクト: FrankHB/YEGE
int loop()
{
	startInf();
	HWND hwnd = ::FindWindowA(NULL,"easyNote");
	SetTransparent(hwnd,215);
	while(1)
	{
		view();
		setcolor(RED);
		moveWindow(hwnd);
		doubleThing(inf.page-1);
		putTitle(th[0].title,BLUE);
		putThing(inf.screen_x,inf.screen_y,inf.box_y,th[0].thing,RED);
		putTime();
		drawMouse(mouse(X),mouse(Y),WHITE);
		if(keystate(VK_ESCAPE)&&keystate(VK_LBUTTON))
			break;
		delay_fps(100);
		cleardevice();
	}
	return 0;
}
コード例 #6
0
ファイル: pollingserver.c プロジェクト: uwevil/ASTRE
void *runPollingServer (void *t){
  TaskInfo           s;
  EventInfo          e;
  TimeSpan           c = 0;
  Time               d = 0;
  int                i;
  
  s = periodicTaskTable[*(int *)t];

  // Schedule the initial replenishment event
  e.kind        = PRODUCE;
  e.name        = s.name;
  e.activation  = nextActivation (s.period);
  e.computation = s.computation;
  s.computation = 0;
  appendEvent (e);

  // Print the event pushed in the queue
  putHeader (s.name);
  putString ("@");
  putTime   (e.activation);
  putString (" ");
  putString (s.name);
  putString ("=+");
  putTime   (e.computation);
  newLine ();

  while (systemNotCompleted () && (0 <= lastEvent)) {
    e = getEvent (firstEvent);

    // When the first event to handle happens in the future, release the
    // server budget
    // NYI("if next event happens in the future, release the server budget"); recharger
    //**********************************************************************
    if ((((localClock() + 10000) / s.period) * s.period) < e.activation){
	s.computation = 0;
     }
   
    // Before handling next event check the server budget is not empty
    if (s.computation == 0) {

      // Look for the first PRODUCE event
      for (i=firstEvent; i <= lastEvent; i++){
	e = getEvent(i);
	if (e.kind == PRODUCE) {
	  if (systemCompletedAt (e.activation)) {
	    return NULL;
	  }

	  // Remove PRODUCE event and then wait for its activation time.
	  //  NYI("remove event and wait for its activation");
	  //****************************************************************
	  removeEvent(i);
	  delayUntil(e.activation);

	  
	  // Update the server budget and schedule the next PRODUCE
	  // event. To do so compute the next activation time and the
	  // computation time related to this replenishment event.
	  // NYI("update server budget and schedule replenishment");
	  //******************************************************************
	  s.computation = e.computation;
	  e.activation  = nextActivation (s.period);
	  appendEvent (e);

	  
	  // Print the arrival of this event
	  putHeader (s.name);
	  putString (s.name);
	  putString ("=+");
	  putTime   (e.computation);
	  newLine ();

	  // Print the event pushed in the queue
	  putHeader (s.name);
	  putString ("@");
	  putTime   (e.activation);
	  putString (" ");
	  putString (s.name);
	  putString ("=+");
	  putTime   (e.computation);
	  newLine ();
      
	  break;
	}
      }
    }

    e = getEvent (firstEvent);
    if (systemCompletedAt (e.activation)){
      return NULL;
    }

    if (e.kind == PRODUCE) {
      // Remove PRODUCE event and then wait for its activation time
      // NYI("remove event and wait for its activation time");
      //*******************************************************************
      removeEvent(firstEvent);
      delayUntil(e.activation);

      
      // As there are no Consume events to handle, the server discards
      // its budget. But it schedules its replenishment.
      //  NYI ("update server budget and schedule its replenishment");
      //***************************************************************
      s.computation = e.computation;
      e.activation  = nextActivation (s.period);
      appendEvent (e);

      // Print the event pushed in the queue
      putHeader (s.name);
      putString ("@");
      putTime   (e.activation);
      putString (" ");
      putString (s.name);
      putString ("=+");
      putTime   (e.computation);
      newLine ();
      
    } else {

      // Wait for event activation
      // NYI("wait for event activation");
      delayUntil(e.activation);
      

      // Evaluate the computation time needed to handle this
      // event that is the computation time requested and the
      // one available on the server.
      // NYI ("evaluate computation time for event");
      //***********************************************
      c = e.computation;
      
      // Update computation time needed to complete event in queue.
      // Remove the event once it is completed.
      // Do not update server budget yet.
      // We want to print the server status before and after this operation.
      // NYI("evaluate remaining computation time of current event");
      // NYI("remove event when completed");
      //NYI("update event in queue when not completed");
      //***********************************************************************

      if (e.computation <= s.computation){
	e.computation = 0;
	removeEvent(firstEvent);
      }else{
	removeEvent(firstEvent);
	 e.computation = e.computation - s.computation;
	 e.activation  = e.activation + 1;
	 appendEvent (e);
	 c = s.computation;
      }
      
      // Print status of both server and event status
      putHeader    (s.name);
      putString    (s.name);
      putString    ("=");
      putTime      (s.computation);
      putString    ("-");
      putTime      (c);
      putString    (" ");
      putString    (e.name);
      putString    ("=");
      putTime      (e.computation);
      newLine ();
      
      // Update the server budget after this operation.
      
      // Simulate the execution of this event using
      // computeDuringTimeSpan. Provide the name of the event, its
      // worst case execution time, and the period of the server.
      // ATTENTION : the period parameter in computeDuringTimeSPan is
      // used to compute the execution priority. See tasks.h.
      //   NYI("update server budget");
      //  NYI("compute event");
      if (e.computation > 0){
	computeDuringTimeSpan(e.name, s.computation, s.period);
	s.computation = 0;
      }else{
	computeDuringTimeSpan(e.name, c, s.period);
	s.computation -= c;
      }
      
      

      // Print event completion if needed
      if (e.computation == 0) {
	putHeader    (s.name);
	putString    ("completed ");
	putString    (e.name);
	newLine ();
      }
    }
  }

  return NULL;
}