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

Associating pthread_t with a thread descriptor impossible #4032

Closed
vicuna opened this issue May 26, 2006 · 2 comments
Closed

Associating pthread_t with a thread descriptor impossible #4032

vicuna opened this issue May 26, 2006 · 2 comments

Comments

@vicuna
Copy link

vicuna commented May 26, 2006

Original bug ID: 4032
Reporter: @mmottl
Status: acknowledged (set by @xavierleroy on 2006-06-13T09:35:59Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.09.2
Category: otherlibs
Tags: patch
Monitored by: letaris @mmottl

Bug description

This is an important feature that is missing from the current OCaml-implementation: it is currently not possible to extract the pthread_t associated with a thread (thread descriptor). This means it is impossible to implement certain POSIX-functions (e.g. pthread_getcpuclockid, etc.) operating on threads (other than the currently executing one - we can always get this one with pthread_self()) without hacking the OCaml-runtime sources.

Why not e.g. just store the pthread_t of a thread in its descriptor?

@vicuna
Copy link
Author

vicuna commented Jun 1, 2006

Comment author: bhurt-aw

The specific file you have to hack is posix.c in the otherlibs/systhreads library. What this file needs is a function like:

pthread_t get_pthread_t (Value descr) {
/* Get the associated pthread_t for a given thread descriptor */
caml_thread_t curr;

curr = curr_thread;
do {
    if (curr->descr == descr) {
        return curr->pthread;
    }
    curr = curr->next;
} while (curr != curr_thread);
return NULL;

}

Unfortunately, this routine needs a number of definitions out of the posix.c file (the definition of caml_thread_t if nothing else).

Note that this function doesn't scale well with large numbers of threads- in that case, some better solution might be engineered.

@github-actions
Copy link

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

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