open_posix: condvar/schedule: remove signal handlers

POSIX states:
"It is not safe to use the pthread_cond_signal() function in a signal
handler that is invoked asynchronously. Even if it were safe, there
would still be a race between the test of the Boolean pthread_cond_wait()
that could not be efficiently eliminated."

Further, this test could hang on single CPU, if signal gets delivered
to main thread, because there is low prio thread busy looping with
higher priority than main.

This patch removes signal handlers and instead uses main to
signal/unlock condition/barrier/mutex that high prio thread is
blocked on.

High and low prio threads are set to run on same CPU to check that
high prio thread really preempted low prio thread regarless of number
of CPUs on system. Main thread's priority is at least the same as
low prio thread, therefore it should eventually run even if there
is only single CPU on system.

Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Acked-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Jan Stancek <jstancek@redhat.com>
4 files changed