[LTP] [PATCH/RFC] sem_post/8-1: improve "child blocked on semaphore" detection
Jan Stancek
jstancek@redhat.com
Tue Mar 7 15:41:35 CET 2017
----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: ltp@lists.linux.it
> Sent: Tuesday, 7 March, 2017 3:16:56 PM
> Subject: Re: [LTP] [PATCH/RFC] sem_post/8-1: improve "child blocked on semaphore" detection
<snip>
> > c_3 = fork();
> > switch (c_3) {
> > @@ -204,7 +206,7 @@ int main(void)
> > usleep(100);
> > sem_getvalue(sem_1, &val);
> > } while (val != 0);
> > - usleep(100);
> > + tst_process_state_wait3(c_3, 'S', 2000);
>
> So sem_1 semaphore is used just as a counter and we are fixing race
> before the children decrement its value and lock on the second
> semaphore, right?
Yes, because we can't query "sem" (Posix semaphore) directly
to see how many processes are waiting. This is possible only
in System V semaphores: semctl(GETNCNT).
> The approach here seems reasonable, acked.
<snip>
> > +int tst_process_state_wait3(pid_t pid, const char state,
> > + unsigned long maxwait_ms)
> > +{
> > + usleep(maxwait_ms * 1000);
>
> return 0; here?
>
> We don't handle it anyway but missing return would produce a warning...
Right, I'll fix that before push.
Thanks,
Jan
>
> > +}
> > +#endif
> > --
> > 1.8.3.1
> >
> >
> > --
> > Mailing list info: https://lists.linux.it/listinfo/ltp
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
More information about the ltp
mailing list