public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH/RFC] sem_post/8-1: improve "child blocked on semaphore" detection
Date: Tue, 7 Mar 2017 09:41:35 -0500 (EST)	[thread overview]
Message-ID: <1323115136.4453230.1488897695040.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20170307141656.GB8709@rei.lan>



----- 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
> 

      reply	other threads:[~2017-03-07 14:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03 11:53 [LTP] [PATCH/RFC] sem_post/8-1: improve "child blocked on semaphore" detection Jan Stancek
2017-03-07 14:16 ` Cyril Hrubis
2017-03-07 14:41   ` Jan Stancek [this message]

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=1323115136.4453230.1488897695040.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.com \
    --cc=ltp@lists.linux.it \
    /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