minor patch for kernel/sched.c

Ulrich Windl (Ulrich.Windl@rz.uni-regensburg.de)
Tue, 28 May 1996 07:56:14 +0200


--Message-Boundary-19421
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

Here's a small patch to change a few things in sched.c. These are not
bugs in the strict sense, but look at the modifications yourself and
build your own opinion...

Ulrich

--Message-Boundary-19421
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Text from file 'sched~1.c-p'

This patch to kernel/sched.c changes a few very strange code constructs to
be (hopefully) more understandable. Also added better rounding to nanosleep
function. Some very long string constants in printk have been split into
shorter lines. Added and corrected some comments.

Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>

--- sched.c 1996/05/12 18:08:12 1.5
+++ sched.c 1996/05/27 14:54:01 1.6
@@ -230,7 +230,7 @@
* 0: out of time, recalculate counters (but it might still be
* selected)
* +ve: "goodness" value (the larger, the better)
- * +1000: realtime process, select this.
+ * >= +1000: realtime process, select this.
*/
static inline int goodness(struct task_struct * p, struct task_struct * prev, int this_cpu)
{
@@ -1279,6 +1279,7 @@

t.tv_sec = 0;
t.tv_nsec = 0; /* <-- Linus, please fill correct value in here */
+ /* is this ``"number of running processes" * "timeslice"'' ? */
return -ENOSYS; /* and then delete this line. Thanks! */
memcpy_tofs(interval, &t, sizeof(struct timespec));

@@ -1296,7 +1297,7 @@

if (sec > (LONG_MAX / HZ))
return LONG_MAX;
- nsec += 1000000000L / HZ - 1;
+ nsec += 500000000L / HZ; /* round to the nearest jiffy */
nsec /= 1000000000L / HZ;
return HZ * sec + nsec;
}
@@ -1333,20 +1334,21 @@
/*
* Short delay requests up to 2 ms will be handled with
* high precision by a busy wait for all real-time processes.
+ * We might lose up to 500ns when calling udelay(), but we
+ * are closer to the requested delay than with rounding-up.
*/
- udelay((t.tv_nsec + 999) / 1000);
+ udelay((t.tv_nsec + 500) / 1000);
return 0;
}

- expire = timespectojiffies(&t) + (t.tv_sec || t.tv_nsec) + jiffies;
+ expire = timespectojiffies(&t) + jiffies;
current->timeout = expire;
current->state = TASK_INTERRUPTIBLE;
schedule();

if (expire > jiffies) {
if (rmtp) {
- jiffiestotimespec(expire - jiffies -
- (expire > jiffies + 1), &t);
+ jiffiestotimespec(expire - jiffies, &t);
memcpy_tofs(rmtp, &t, sizeof(struct timespec));
}
return -EINTR;
@@ -1376,7 +1378,7 @@
else
printk(" %016lx ", thread_saved_pc(&p->tss));
#endif
- for (free = 1; free < PAGE_SIZE/sizeof(long) ; free++) {
+ for (free = 1; free < PAGE_SIZE/sizeof(long); free++) {
if (((unsigned long *)p->kernel_stack_page)[free])
break;
}
@@ -1399,15 +1401,15 @@
{
int i;

+ printk("\n "
#if ((~0UL) == 0xffffffff)
- printk("\n"
- " free sibling\n");
- printk(" task PC stack pid father child younger older\n");
+ "free sibling\n"
+ " task PC "
#else
- printk("\n"
- " free sibling\n");
- printk(" task PC stack pid father child younger older\n");
+ " free sibling\n"
+ " task PC "
#endif
+ "stack pid father child younger older\n");
for (i=0 ; i<NR_TASKS ; i++)
if (task[i])
show_task(i,task[i]);

--Message-Boundary-19421--