From: Rusty Russell <rusty@rustcorp.com.au>
To: frankeh@watson.ibm.com
Cc: torvalds@transmeta.com, linux-kernel@vger.kernel.org,
lse-tech@lists.sourceforge.net
Subject: Re: Futexes V :
Date: Thu, 7 Mar 2002 15:21:31 +1100 [thread overview]
Message-ID: <20020307152131.610b4c2e.rusty@rustcorp.com.au> (raw)
In-Reply-To: <20020306203522.4994A3FE06@smtp.linux.ibm.com>
In-Reply-To: <E16i8x2-0008TV-00@wagner.rustcorp.com.au> <20020306185420.29df1bf2.rusty@rustcorp.com.au> <20020306161229.0821D3FE06@smtp.linux.ibm.com> <20020306203522.4994A3FE06@smtp.linux.ibm.com>
On Wed, 6 Mar 2002 15:36:25 -0500
Hubertus Franke <frankeh@watson.ibm.com> wrote:
> On Wednesday 06 March 2002 11:13 am, Hubertus Franke wrote:
>
> I cut a new version with what I was previously discussing.
> Now we have two kind of wakeup mechanism
>
> (a) regular wakeup (as was) which basically gives you convoy avoidance
> (b) fair wakeup (will first wake a waiting process up .. FIFO)
>
> Basically integrated 2 prior patches of Rusty
I like your numbers. Since I think fairness is nice, but lack of starvation
is vital, I've been trying to starve a process.
So far, I've not managed it. Please hack on the below code, and see if
you can manage it. If not, I think we can say "not a problem in real life",
and just stick with the fastest implementation.
Thanks!
Rusty.
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <sys/time.h>
#include <time.h>
#include <signal.h>
#include "usersem.h"
#ifndef PROT_SEM
#define PROT_SEM 0x8
#endif
static void spinner(struct futex *sem, int hold)
{
while (1) {
futex_down(sem);
if (hold) sleep(1);
futex_up(sem);
}
}
/* Test maximum time to lock given furious spinners. */
int main(int argc, char *argv[])
{
struct futex *sem;
unsigned int i;
unsigned long maxtime = 0;
pid_t children[100];
if (argc != 3) {
fprintf(stderr, "Usage: starve <numspinners> <iterations>\n");
exit(1);
}
sem = malloc(sizeof(*sem));
futex_region(sem, sizeof(*sem));
futex_init(sem);
for (i = 0; i < atoi(argv[1]); i++) {
children[i] = fork();
if (children[i] == 0)
spinner(sem, i < atoi(argv[1])/2);
}
for (i = 0; i < atoi(argv[2]); i++) {
struct timeval start, end, diff;
sleep(1);
gettimeofday(&start, NULL);
futex_down(sem);
gettimeofday(&end, NULL);
futex_up(sem);
timersub(&end, &start, &diff);
printf("Wait time: %lu.%06lu\n", diff.tv_sec, diff.tv_usec);
if (diff.tv_sec * 1000000 + diff.tv_usec > maxtime)
maxtime = diff.tv_sec * 1000000 + diff.tv_usec;
}
/* Kill children */
for (i = 0; i < atoi(argv[1]); i++)
kill(children[i], SIGTERM);
printf("Worst case: %lu\n", maxtime);
exit(0);
}
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next prev parent reply other threads:[~2002-03-07 4:18 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-05 7:01 [PATCH] Futexes IV (Fast Lightweight Userspace Semaphores) Rusty Russell
2002-03-05 21:23 ` Futexes III : performance numbers Hubertus Franke
2002-03-06 2:08 ` Rusty Russell
2002-03-06 14:28 ` Hubertus Franke
2002-03-06 17:23 ` [Lse-tech] " george anzinger
2002-03-07 0:25 ` Hubertus Franke
2002-03-07 0:35 ` Hubertus Franke
2002-03-06 7:54 ` Rusty Russell
2002-03-06 14:46 ` Hubertus Franke
2002-03-06 16:13 ` Hubertus Franke
2002-03-06 20:36 ` Futexes V : Hubertus Franke
2002-03-07 4:21 ` Rusty Russell [this message]
2002-03-05 22:39 ` [PATCH] Futexes IV (Fast Lightweight Userspace Semaphores) Davide Libenzi
2002-03-05 23:16 ` Hubertus Franke
2002-03-05 23:26 ` Davide Libenzi
2002-03-05 23:37 ` Peter Svensson
2002-03-05 23:50 ` Davide Libenzi
2002-03-08 0:07 ` Richard Henderson
2002-03-06 1:46 ` Rusty Russell
2002-03-06 2:03 ` Davide Libenzi
2002-03-08 18:07 ` Linus Torvalds
2002-03-08 19:03 ` Hubertus Franke
2002-03-08 19:22 ` Linus Torvalds
2002-03-08 20:29 ` Hubertus Franke
2002-03-08 20:48 ` Matthew Kirkwood
2002-03-08 21:02 ` Linus Torvalds
2002-03-08 23:15 ` Hubertus Franke
2002-03-08 23:36 ` Alan Cox
2002-03-08 23:41 ` Linus Torvalds
2002-03-08 23:56 ` Hubertus Franke
2002-03-09 2:12 ` Linus Torvalds
2002-03-11 14:14 ` Hubertus Franke
2002-03-09 0:03 ` H. Peter Anvin
2002-03-09 1:15 ` Alan Cox
2002-03-10 19:41 ` Linus Torvalds
2002-03-11 20:49 ` Pavel Machek
2002-03-13 7:40 ` Rusty Russell
2002-03-13 16:37 ` Alan Cox
2002-03-10 19:58 ` Martin J. Bligh
2002-03-10 20:40 ` Alan Cox
2002-03-10 20:28 ` Martin J. Bligh
2002-03-10 21:05 ` Alan Cox
2002-03-12 9:35 ` Helge Hafting
2002-03-08 20:40 ` Alan Cox
2002-03-08 20:57 ` Linus Torvalds
2002-03-08 23:43 ` H. Peter Anvin
2002-03-08 22:55 ` Hubertus Franke
2002-03-08 23:38 ` Alan Cox
2002-03-08 23:44 ` H. Peter Anvin
2002-03-08 20:47 ` george anzinger
2002-03-08 23:02 ` Hubertus Franke
2002-03-08 23:47 ` george anzinger
2002-03-09 1:11 ` Alan Cox
2002-03-09 1:20 ` Linus Torvalds
2002-03-09 4:49 ` Rusty Russell
2002-03-11 22:45 ` Linus Torvalds
2002-03-11 23:12 ` Hubertus Franke
2002-03-12 7:20 ` Rusty Russell
2002-03-12 14:56 ` Hubertus Franke
2002-03-13 4:02 ` Rusty Russell
2002-03-12 17:17 ` Linus Torvalds
2002-03-13 2:57 ` Rusty Russell
2002-03-09 4:51 ` Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020307152131.610b4c2e.rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=frankeh@watson.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lse-tech@lists.sourceforge.net \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox