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

Thread scheduling problem with native pthreads #7997

Closed
vicuna opened this issue Jan 21, 2003 · 1 comment
Closed

Thread scheduling problem with native pthreads #7997

vicuna opened this issue Jan 21, 2003 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Jan 21, 2003

Original bug ID: 1524
Reporter: administrator
Status: closed
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Chris Uzdavinis
Version: 3.06
OS: Linux 7.2 (enigma) and 7.3 (Valhalla)
Submission from: external.atdesk.com (63.68.0.194)

The following program does not terminate. One of the threads is not being
scheduled. This problem occurs only when compiled to native code. With
bytecode, it works correctly. (I built ocaml with -with-pthread option).

let keep_going = ref true;;
let n = ref 0;;

let f_proc1 () =
while !keep_going do
incr n;
done

let f_proc2 () =
let t2 = Thread.create f_proc1 () in
let t3 = Thread.create f_proc1 () in
Thread.delay 3.0; (* Problem here: never returns *)
Printf.printf "exiting f_proc2...\n";
flush stdout;;

let t1 = Thread.create f_proc2 () in
Thread.join t1;
Printf.printf "exiting main thread...\n"


Workaround:
If I put a "Thread.yield ()" call into the f_proc1 loop (or any call to delay in
the loop), then everything properly executes. I don't think this should be
necessary, though.

What concerns me the most is different behavior at runtime depending on the
compiler used (native or bytecode.)

@vicuna
Copy link
Author

vicuna commented Feb 11, 2003

Comment author: administrator

Bytecode and native-code poll for context switching at different times.
Native polls at allocation points only. That explains the difference.
It is unlikely that we'll introduce more poll points in generated native code.

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

No branches or pull requests

1 participant