lkml.org 
[lkml]   [1998]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectScheduler latency
  Hi, all. I've noticed that the scheduler in linux 2.1.79 seems a lot
slower than the one in 2.0.25. Results of timing sched_yield(2):

PPro/180 running 2.1.79:
SCHED_OTHER class: 56 microseconds
SCHED_FIFO class: 3 microseconds

P133 running 2.0.25:
SCHED_OTHER class: 4 microseconds
SCHED_FIFO class: 4 microseconds

Does this result surprise anyone? I had hoped that the 2.1.x series
was faster :-/

Regards,

Richard....
===============================================================================
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <sched.h>
#include <errno.h>

#define DEFAULT_ITERS 1000
#define ERRSTRING strerror (errno)

int main (int argc, char **argv)
{
int count;
int num_iters = DEFAULT_ITERS;
long time_taken;
struct timeval start_time, stop_time;
struct sched_param sp;

if (argc > 1) num_iters = atoi (argv[1]);
if (geteuid () == 0)
{
sp.sched_priority = 99;
if (sched_setscheduler (0, SCHED_FIFO, &sp) != 0)
{
fprintf (stderr,
"Error setting scheduling class to SCHED_FIFO\t%s\n",
ERRSTRING);
exit (1);
}
fprintf(stderr,
"Timing %d iterations of sched_yield(2) in class SCHED_FIFO\n",
num_iters);
}
else
{
fprintf (stderr,
"Timing %d iterations of sched_yield(2) in class SCHED_OTHER\n",
num_iters);
}
if (gettimeofday (&start_time, NULL) != 0)
{
fprintf (stderr, "Error getting start time\t%s\n", ERRSTRING);
exit (1);
}
for (count = 0; count < num_iters; ++count)
{
sched_yield ();
}
if (gettimeofday (&stop_time, NULL) != 0)
{
fprintf (stderr, "Error getting stop time\t%s\n", ERRSTRING);
exit (1);
}
time_taken = (stop_time.tv_sec - start_time.tv_sec) * 1000000;
time_taken += (stop_time.tv_usec - start_time.tv_usec);
fprintf (stderr, "Total time: %ld us\titeration time: %ld us\n",
time_taken, time_taken / num_iters);
} /* End Function main */

\
 
 \ /
  Last update: 2005-03-22 13:41    [W:0.160 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site