I am using TI am335x evm board, and the sdk is Processor SDK Linux for AM335x v05.02.00.10.
I'd like to create a thread,and make this thread run 100ms every time, this thread can be re-scheduled by kernel but I don't want this this thread interrupt too long.
So I use pthread_create and use sched_setparam to set the policty to SCHED_RR, then I check my thread in /proc/(pid)/sched, the policy is indeed sched_rr.
The thread can run about 100ms every time when cpu is not busy. but when cpu is busy (when I copy a big file). this thread can't guarantee about 100ms every execute. it my be interrupt for 800 or 900ms.
Below is my thread function.
void *test(){
struct timeval cur, last;
gettimeofday(&cur, NULL);
int interval;
gettimeofday(&cur, NULL);
int interval;
while(1)
{
last.tv_sec = cur.tv_sec;
last.tv_usec = cur.tv_usec;
{
last.tv_sec = cur.tv_sec;
last.tv_usec = cur.tv_usec;
gettimeofday(&cur, NULL);
interval = (cur.tv_sec-last.tv_sec) * 1000 + (cur.tv_usec - last.tv_usec)/1000;
if (interval > 150)
printf("cur - last = %d ms\n", vv);
interval = (cur.tv_sec-last.tv_sec) * 1000 + (cur.tv_usec - last.tv_usec)/1000;
if (interval > 150)
printf("cur - last = %d ms\n", vv);
usleep(100*1000);
}
}
}
The interval is sometimes more than 150ms, may be 800ms or 900ms, when I copy a big file on board at the same time.
I know the kernel in this sdk is not real time, but the sched_rr thread should not interrupt or re-schedule so long. I use top or ps command to check, there is no other sched_rr task in my system.
I think the thread didn't get execute when cpu is busy, it may busy on system call or kernel task. but shouldn't be so long, is there any special configrations for kernel?
thanks.