Re: Update to the /dev/random driver

Harald Koenig (koenig@tat.physik.uni-tuebingen.de)
Fri, 1 May 1998 11:51:52 +0200


On Apr 30, Billy Harvey wrote:

> I make this distinction versus the concept of nice-ing a process. For example,
> the RC5 process on my system still takes up too much of my useful CPU time. I
> only want some things working when I have *nothing* else to do.

having had the same problem, I got the patch below for Linux 2.0.x
from Ingo Molnar which adds a new scheduler class SCHED_IDLE.

here is a small program which I'm usually using to start these idle tasks
with
sched_idle programm args...

(similar to `nice .... ')

-------------------------------------------------------------------------------
/* sched_idle.c, (C) 1997 H. Koenig, put under GPL */

#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <linux/sched.h>

main(int argc, char *argv[])
{
struct sched_param sp;
int nicelevel = 19;

if (argc <= 1) {
printf("usage: %s program [ arguments... ]\n",argv[0]);
exit(1);
}

sp.sched_priority = 1;
sched_setscheduler(0, SCHED_IDLE, &sp);

if (nice(nicelevel) == -1) {
perror("nice");
exit(1);
}

argv++;
execv(argv[0], argv);

perror("exec");
exit(1);
}

-------------------------------------------------------------------------------

using Ingo's `nice' kernel patch:

-------------------------------------------------------------------------------
diff -ur linux/include/linux/sched.h ./include/linux/sched.h
--- linux/include/linux/sched.h Sat Mar 29 01:08:17 1997
+++ ./include/linux/sched.h Thu Apr 17 13:35:48 1997
@@ -93,6 +93,7 @@
#define SCHED_OTHER 0
#define SCHED_FIFO 1
#define SCHED_RR 2
+#define SCHED_IDLE 3

struct sched_param {
int sched_priority;
@@ -210,7 +211,8 @@
struct wait_queue *wait_chldexit; /* for wait4() */
unsigned short uid,euid,suid,fsuid;
unsigned short gid,egid,sgid,fsgid;
- unsigned long timeout, policy, rt_priority;
+ unsigned long timeout, policy;
+ long rt_priority;
unsigned long it_real_value, it_prof_value, it_virt_value;
unsigned long it_real_incr, it_prof_incr, it_virt_incr;
struct timer_list real_timer;
diff -ur linux/kernel/sched.c ./kernel/sched.c
--- linux/kernel/sched.c Tue Apr 8 17:47:47 1997
+++ ./kernel/sched.c Tue Apr 29 18:29:39 1997
@@ -1380,7 +1380,7 @@
if (policy < 0)
policy = p->policy;
else if (policy != SCHED_FIFO && policy != SCHED_RR &&
- policy != SCHED_OTHER)
+ policy != SCHED_OTHER && policy != SCHED_IDLE)
return -EINVAL;

/*
@@ -1399,7 +1399,15 @@
return -EPERM;

p->policy = policy;
- p->rt_priority = lp.sched_priority;
+
+ if (policy == SCHED_IDLE)
+ /*
+ * look into goodness() before complaining ;)
+ */
+ p->rt_priority = -1999 + lp.sched_priority;
+ else
+ p->rt_priority = lp.sched_priority;
+
cli();
if (p->next_run)
move_last_runqueue(p);
-------------------------------------------------------------------------------

Harald

--
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu