|
From: Bart V. A. <bar...@gm...> - 2006-08-26 18:07:42
|
Hello Julian,
Regarding thread state: I commented out tst->status = VgTs_Empty in the
assembly code cited below because I moved it to another point
(m_scheduler.c, case VG_USERREQ__POST_PTHREAD_JOIN). The background of this
change is as follows:
- After the client finished calling pthread_join(), drd needs to know both
the thread IDs of the thread that called pthread_join() and the the ID of
the joined thread. Once pthread_join() finishes, the client knows the
identity of both threads, but both IDs are of type pthread_t.
- drd uses ThreadId's internally. Hence, I needed a way to map pthread_t
into ThreadId. I had two options for storing the translation data between
these two types of thread IDs: either in the Valgrind core or in the client.
- When storing the translation information between pthread_t and ThreadId in
Valgrind, this translation information must still be accessible at the time
VG_USERREQ__POST_PTHREAD_JOIN is handled. This is why I postponed cleanup of
the per-thread data in Valgrind.
- Another option is to store the relationship between pthread_t and ThreadId
in the client. I can't solve this with thread-local storage since this
information is no longer accessible once pthread_join() completes
(pthread_key_create()/pthread_key_delete()/pthread_setspecific()/pthread_getspecific()).
Note: this change breaks clone() calls that do not originate from
pthread_create(). This can be solved by initializing the pthread_t value
kept for threads created by raw clone() calls to zero, and by executing the
statement "movl %1, %0\n" conditionally (only for threads created by raw
clone() calls). I did not yet implement this byself because I'm not that
fluent in assembly language.
Do you have any suggestions for alternative implementations ?
On 8/26/06, Julian Seward <js...@ac...> wrote:
>
>
>
> asm volatile (
> - "movl %1, %0\n" /* set tst->status = VgTs_Empty */
> + // "movl %1, %0\n" /* set tst->status = VgTs_Empty */
> "movl %2, %%eax\n" /* set %eax = __NR_exit */
> "movl %3, %%ebx\n" /* set %ebx = tst->os_state.exitcode */
> "int $0x80\n" /* exit(tst->os_state.exitcode) */
>
> etc. So, I'm really not enthusiastic about messing with the
> scheduler's state machine. You made some comment about why this
> is necessary, but now I can't find that email. Something to do
> with clone?
>
|