From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cs3.bu.edu (cs3.bu.edu [128.197.12.8]) by ozlabs.org (Postfix) with ESMTP id 4AA42DDDFC for ; Wed, 12 Sep 2007 09:00:01 +1000 (EST) From: "Ilya Lipovsky" To: "'Benedict, Michael'" , Subject: RE: futex priority based wakeup Date: Tue, 11 Sep 2007 18:59:28 -0400 Message-ID: <000001c7f4c7$7a7ab5c0$3a0d10ac@Radstone.Local> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" In-Reply-To: List-Id: Linux on Embedded PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Hmm. Just for kicks - inside the important thread could you add: int curpolicy; struct sched_param sp; pthread_getschedparam (pthread_self (), &curpolicy, &sp) printf("important's policy is %d and priority is %d\n", curpolicy, sp.__sched_priority); before the very first futex syscall and after your "printf("important got futex!\n");" line. Do similar for the unimportant thread, and see if you get anything weird - e.g. priorities come out to be the same for threads. -----Original Message----- From: linuxppc-embedded-bounces+lipovsky=cs.bu.edu@ozlabs.org [mailto:linuxppc-embedded-bounces+lipovsky=cs.bu.edu@ozlabs.org] On Behalf Of Benedict, Michael Sent: Monday, September 10, 2007 5:41 PM To: linuxppc-embedded@ozlabs.org Subject: RE: futex priority based wakeup Ilya Lipovsky wrote: > Your code looks correct to me, so if the kernel developers > did their job > correctly, the only potentially weak link is glibc. > Well, either the kernel developers didn't do their job, or I am missing something. The following also fails, and it should be bypassing glibc: #define _XOPEN_SOURCE 600 #include #include #include #include #include #include #include #include #include int myfutex = 0; void *important(void *ign) { sleep(1); printf("important waiting for futex\n"); fflush(stdout); if(syscall(SYS_futex, &myfutex, FUTEX_WAIT, 0, NULL)) { perror("futex"); exit(1); } else { printf("important got futex!\n"); fflush(stdout); syscall(SYS_futex, &myfutex, FUTEX_WAKE, 1, NULL); } return NULL; } void *unimportant(void *ign) { printf("unimportant waiting for futex\n"); fflush(stdout); if(syscall(SYS_futex, &myfutex, FUTEX_WAIT, 0, NULL)) { perror("futex"); exit(1); } else { printf("unimportant got futex!\n"); fflush(stdout); syscall(SYS_futex, &myfutex, FUTEX_WAKE, 1, NULL); } return NULL; } int main() { struct sched_param p; pthread_attr_t attr; pthread_t i, u; p.__sched_priority = sched_get_priority_min(SCHED_FIFO); if(-1 == p.__sched_priority) { perror("sched_get_priority_min"); return 1; } pthread_attr_init(&attr); pthread_attr_setschedpolicy(&attr, SCHED_FIFO); pthread_attr_setschedparam(&attr, &p); pthread_create(&u, &attr, unimportant, NULL); p.__sched_priority = sched_get_priority_max(SCHED_FIFO); pthread_attr_setschedparam(&attr, &p); pthread_create(&i, &attr, important, NULL); sleep(5); printf("futex FUTEX_WAKE\n"); fflush(stdout); syscall(SYS_futex, &myfutex, FUTEX_WAKE, 1, NULL); pthread_join(u, NULL); pthread_join(i, NULL); return 0; } Which produces: unimportant waiting for futex important waiting for futex futex FUTEX_WAKE unimportant got futex! important got futex! Could someone with 2.6.22 please verify? _______________________________________________ Linuxppc-embedded mailing list Linuxppc-embedded@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-embedded