Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

condition_variable::wait() does not suspend current thread #72

Open
LnnrtS opened this issue Feb 26, 2021 · 2 comments
Open

condition_variable::wait() does not suspend current thread #72

LnnrtS opened this issue Feb 26, 2021 · 2 comments

Comments

@LnnrtS
Copy link
Contributor

LnnrtS commented Feb 26, 2021

mutex mtx;
condition_variable cv;
bool condition;

this will busy loop whereas it should wait to be rescheduled by a call to signal() from a different thread

mtx.lock();
while (condition == false)
{
  cv.wait(mtx);
}
mtx.unlock();

I think there something like
scheduler::internal_link_node (list_, node);
missing between these lines

@LnnrtS
Copy link
Contributor Author

LnnrtS commented Feb 26, 2021

As a quick test I added

{
 scheduler::critical_section scs;
 interrupts::critical_section ics;

 port::this_thread::prepare_suspend ();
 node.thread_->state_ = thread::state::suspended;
}

port::scheduler::reschedule ();

which seems to have fixed the issue.
Not sure if that's the correct fix though..

@ilg-ul
Copy link
Contributor

ilg-ul commented Feb 26, 2021

I don't remember the implementation details now, but normally wait() should relinquish control.

If it does not, it should be fixed.

I don't know how, but entering both critical sections does not look right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants