extern void * worker (void * arg) { // Repeatedly do the following: // malloc a given-sized object, // repeatedly write on it, // then free it. int i, j, k; /* Loop control variables */ struct workerArg * w = (struct workerArg *) arg; setCPU(w->_cpu); for (i = 0; i < w->_iterations; i++) { // Allocate the object. char * obj = (char *)mm_malloc(w->_objSize); // Write into it a bunch of times. for (j = 0; j < w->_repetitions; j++) { for (k = 0; k < w->_objSize; k++) { obj[k] = (char) k; volatile char ch = obj[k]; ch++; } } // Free the object. mm_free(obj); } mm_free(w); return NULL; }
LinuxMode::LinuxMode(ThreadMode m, TaskInfo* task): old_thread_data(Scheduler::GetThreadSpecificUvalSelf()), mode(m), flags(0), vpid(Scheduler::GetVP()), ti(task), global_lock_depth(0) { Scheduler::SetThreadSpecificUvalSelf((uval)this); cpu = INVALID_CPU; setCPU(); };
void moreInfo::reshow(){ delete ui; ui = new Ui::moreInfo; ui->setupUi(this); QString detStats = machine->getDetStatsString(); QStringList noHash = detStats.split("#"); QStringList* allInfo = parseDetailed(noHash); setNetw(allInfo[0]); setCPU(allInfo[1]); setRAM(allInfo[2]); setHDD(allInfo[3]); setProcesses(allInfo[4]); machine->getDetStats(); }
moreInfo::moreInfo(Machine* m, QWidget *parent) : QMainWindow(parent), ui(new Ui::moreInfo) { machine = m; ui->setupUi(this); QString detStats = machine->getDetStatsString(); QStringList noHash = detStats.split("#"); QStringList* allInfo = parseDetailed(noHash); setNetw(allInfo[0]); setCPU(allInfo[1]); setRAM(allInfo[2]); setHDD(allInfo[3]); setProcesses(allInfo[4]); machine->getDetStats(); update = new QTimer(this); update->setInterval(10000); connect(update, SIGNAL(timeout()), this, SLOT(reshow())); update->start(); }
static void * exercise_heap( void *pinput) { thread_data *pdea; int cblks=0 ; int victim ; long blk_size ; int range ; if( stopflag ) { printf("thread %u stopping immediately\n",((thread_data *)pinput)->threadno); return 0; } pdea = (thread_data *)pinput ; setCPU(pdea->threadno % numCPU); /*printf("Thread %u starting exercise, nthreads=%d\n",pdea->threadno,pdea->cThreads) ;*/ pdea->finished = FALSE ; pdea->cThreads++ ; range = pdea->max_size - pdea->min_size ; /* allocate NumBlocks chunks of random size */ for( cblks=0; cblks<pdea->NumBlocks; cblks++){ victim = lran2(&pdea->rgen)%pdea->asize ; mm_free(pdea->array[victim]) ; pdea->cFrees++ ; if (range == 0) { blk_size = pdea->min_size; } else { blk_size = pdea->min_size+lran2(&pdea->rgen)%range ; } pdea->array[victim] = (char *) mm_malloc(blk_size) ; pdea->blksize[victim] = blk_size ; assert(pdea->array[victim] != NULL) ; pdea->cAllocs++ ; /* Write something! */ volatile char * chptr = ((char *) pdea->array[victim]); *chptr++ = 'a'; volatile char ch = *((char *) pdea->array[victim]); (void)ch; *chptr = 'b'; if( stopflag ) break ; } //printf("Thread %u terminating: %d allocs, %d frees\n", // pdea->threadno, pdea->cAllocs, pdea->cFrees) ; pdea->finished = TRUE ; if( !stopflag ){ _beginthread(exercise_heap, 0, pdea) ; } else { printf ("thread stopping.\n"); } pthread_exit (NULL); return 0; }