Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004032OCamlOCaml generalpublic2006-05-26 23:292013-09-03 17:10
Reportermottl 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version3.09.2 
Target VersionFixed in Version 
Summary0004032: Associating pthread_t with a thread descriptor impossible
DescriptionThis 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?
Tagspatch
Attached Files

- Relationships

-  Notes
(0003650)
bhurt-aw (reporter)
2006-06-01 23:27

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.

- Issue History
Date Modified Username Field Change
2006-05-26 23:29 mottl New Issue
2006-06-01 23:27 bhurt-aw Note Added: 0003650
2006-06-13 11:35 xleroy Status new => acknowledged
2013-09-03 17:10 doligez Tag Attached: patch


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker