ALT Linux Bugzilla
– Attachment 2213 Details for
Bug 12730
Вызывает зависание SMP-системы
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
mbmon_test.cpp
mbmon_test.cpp (text/plain), 1.62 KB, created by
Roman Savochenko
on 2007-09-29 00:32:45 MSD
(
hide
)
Description:
mbmon_test.cpp
Filename:
MIME Type:
Creator:
Roman Savochenko
Created:
2007-09-29 00:32:45 MSD
Size:
1.62 KB
patch
obsolete
>#include <stdlib.h> >#include <stdio.h> >#include <unistd.h> >#include <signal.h> >#include <time.h> >#include <pthread.h> > >void *Task( void * ) >{ > float prec, prec_max=0.; > long long work_tm, cur_tm; > int per = 100000000; //s > struct timespec get_tm; > > //Calc next work time and sleep > clock_gettime(CLOCK_REALTIME,&get_tm); > work_tm = (long long)get_tm.tv_sec*1000000000+get_tm.tv_nsec; > > for(int i=0; true/*i < 1000*/; i++) > { > char buf[100], name[31]; > float val; > FILE *fp = popen("mbmon -r -c 1","r"); > if( fp == NULL ) return NULL; > > while(fgets(buf,sizeof(buf),fp)) > { > if( sscanf(buf, "%31s : %f", name, &val) != 2 ) continue; > printf("%s : %f\n",name,val); > } > pclose(fp); > > work_tm=work_tm+per; > get_tm.tv_sec = work_tm/1000000000; get_tm.tv_nsec = work_tm%1000000000; > clock_nanosleep(CLOCK_REALTIME,TIMER_ABSTIME,&get_tm,NULL); > clock_gettime(CLOCK_REALTIME,&get_tm); > cur_tm = (long long)get_tm.tv_sec*1000000000+get_tm.tv_nsec; > prec = (float)(cur_tm-work_tm)/1000000.; > if(prec>prec_max) prec_max=prec; > printf("Precission %f ms; max %f\n",prec,prec_max); > } >} > >int main( int argc, char **argv ) >{ > pthread_t pthrid; > pthread_attr_t pthr_attr; > pthread_attr_init(&pthr_attr); > struct sched_param prior; > pthread_attr_setschedpolicy(&pthr_attr,SCHED_RR); > //pthread_attr_setschedpolicy(&pthr_attr,SCHED_OTHER); > prior.__sched_priority=10; > pthread_attr_setschedparam(&pthr_attr,&prior); > pthread_create(&pthrid,&pthr_attr,Task,NULL); > pthread_attr_destroy(&pthr_attr); > > while(true) sleep(100); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 12730
: 2213