Esempio n. 1
0
  void run() {
     suspendCallerUntil(1*SECONDS);
     protector.enter(); 
       xprintf("hier %s\n", name);
       xprintf("at %ld,%09ld: thread started ", SPLIT_SEC_NS(NOW()) ) ;
       xprintf("- scheduleCounter= %ld\n", (long) Scheduler::getScheduleCounter());
     protector.leave();

     for(long i=0; i < max; i++){
        protector.enter(); 
          counter++;
        protector.leave();
     }

     protector.enter(); 
       xprintf("hier %s\n", name);
       xprintf("at %ld,%09ld:", SPLIT_SEC_NS(NOW()));
       xprintf("counter= %ld ", counter);
       xprintf("- scheduleCounter= %ld\n", (long) Scheduler::getScheduleCounter());
     protector.leave();
    
     while(1) {
       xprintf(" %x, = %s beendet semaphore daten: \n", (int)this, name);
       //xprintf(" owenr %x, entercnt =%d\n", (int)protector.owner, (int)protector.ownerEnterCnt); // variables are private
       suspendCallerUntil();
     }
  }
Esempio n. 2
0
void PRINTF_CONDITIONAL(int negligibleLevel, const char* fmt, ...) {
    if(negligibleLevel > printfVerbosity) return;
    Yprintf yprintf;
    va_start(yprintf.ap, fmt);
    if (errorCounter != 0) xprintf("prev-ERR(%ld) -- ", errorCounter);
    if (!Scheduler::isSchedulerRunning()) {
        yprintf.vaprintf(fmt);
    } else {
        printfProtector.enter();
            yprintf.vaprintf(fmt);
        printfProtector.leave();
    }
    FFLUSH();
}
Esempio n. 3
0
void PRINTF(const char* fmt, ...) {
    if(printfVerbosity == 0) return;
    Yprintf yprintf;
    va_start(yprintf.ap, fmt);
    if (errorCounter != 0) xprintf("prev-ERR(%ld) -- ", errorCounter);
    if (!Scheduler::isSchedulerRunning()) {
        yprintf.vaprintf(fmt);
    } else {
        printfProtector.enter();
            yprintf.vaprintf(fmt);
        printfProtector.leave();
    }
    FFLUSH();
}
Esempio n. 4
0
  void run(){
    while(1){
      yield();
      yieldCnt++;
      yieldGlobal++;
      // displays every 100000 times
      if((yieldCnt%100000) == 0){
        long long timeNow = NOW();
        printProtect.enter();
	      PRINTF(" %s: ", getName());
	      PRINTF("cnt = %ld, ", (long)yieldCnt);
	      PRINTF("totalyiels = %ld, ", (long)getScheduleCounter());
	      PRINTF("Time = %3.9f, ", (double)timeNow/SECONDS);
	      PRINTF("nsec/dispatchCnt = %ld  ", (long)( ((double)timeNow / (double)getScheduleCounter()) * NANOSECONDS ) );
	      PRINTF("nsec/yieldCnt = %ld\n", (long)( ((double)timeNow / (double)yieldGlobal         ) * NANOSECONDS ) );
        printProtect.leave();
      }
    }	
  }