9front - general discussion about 9front
 help / color / mirror / Atom feed
From: cinap_lenrek@felloff.net
To: 9front@9front.org
Subject: Re: [9front] Re: commit b3a26fb633f4649fc202b77c0184184b756960e7
Date: Tue, 09 Apr 2024 03:35:20 +0200	[thread overview]
Message-ID: <4AC534CA35A24BB9795CAA0C12A2DEA0@felloff.net> (raw)
In-Reply-To: <ZhR-AdtKy7ksMRme@alice>

> Perhaps I'm missing something but is it safe to call ready
> outside of the p->rlock?

I do not see any issue with calling ready() outside
of the p->rlock.

In sleep, we set the process state to Wakeme
only when we have both locks. From there on, we'r
committed to go to sleep and we can call ready()
on it (once).

Double ready should not happen as we clear r->p and p->r.

> I thought it was a requirement for a Rendez to be kept
> around by other means if there is a possibility that it may
> be accessed by other proc.

I do not know of any such requirements. The sleep and
wakeup paper is also silent on this topic and the bug
is also right there in the listed code.

The only requirement i know is that Proc's must never
be re-used as something other than a Proc.

> So isn't the Rendez on the stack in semacquire the actual problem?

I can see this being a issue also if the Rendez or QLock
is in dynamically allocated memory. Not just the stack.

I also dont like the Rendez on the stack and i know
we can even save some memory by just using &up->sleep
as the rendezvous point instead of embedding it the
Sema struct. But this isnt addressing the problem at hand.

> ...

> The key change is to zero r->p immediately after saving it
> to p so the critical section involving r is just:

>	lock(r)
>	p = r->p
>	r->p = nil
>	unlock(r)

Maybe, tho i wanted to address the problem at hand.

> What do you think?

I'm going back to sleep :)

--
cinap

  reply	other threads:[~2024-04-09  1:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 23:30 Anthony Martin
2024-04-09  1:35 ` cinap_lenrek [this message]
2024-04-09  1:43 ` cinap_lenrek

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=4AC534CA35A24BB9795CAA0C12A2DEA0@felloff.net \
    --to=cinap_lenrek@felloff.net \
    --cc=9front@9front.org \
    /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;
as well as URLs for NNTP newsgroup(s).