[lkml]   [2003]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: fcntl and flock wakeups not FIFO?
Matthew Wilcox wrote:
> [cc'ing the person or list mentioned in MAINTAINERS would get you
> a better response :-P]

Hmm...that might be a good idea. :)

>>I've been doing some experimenting with locking on 2.4.18 and have
>>noticed that if I have a number of writers waiting on a lock, they are
>>not woken up in the order in which they requested the lock.
>>Is this expected? If so, what was the reasoning for this and are there
>>any patches to give FIFO wakeups?
> That certainly isn't what's supposed to happen. They should get woken
> up in-order. The code in 2.4.18 seems to be doing that. Are you
> doing anything clever with scheduling?

Well maybe a little bit on the production box, but I don't think its the
cause since the same thing happens on my home machine with a stock
Mandrake 9 kernel (2.4.19-16mdk).

Here's the test app:

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/file.h>

int main(int argc, char **argv)
int fd = open("/dev/null", O_RDWR);
if (fd < 0)

printf("aquiring exclusive lock\n");
int rc = flock(fd, LOCK_EX);
if (rc < 0)

printf("got lock\n");


return 0;

I start up four different instances of it in different windows, then
kill them (ctrl-c) in the order that I started them.

It doesn't happen every time, but they don't always get the lock in the
same order that I started them.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

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