Page MenuHomeFreeBSD

Switch linuxulator to use the native 1:1 threads.
ClosedPublic

Authored by dchagin on Oct 31 2014, 6:31 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 18, 1:34 AM
Unknown Object (File)
Mar 29 2024, 1:15 PM
Unknown Object (File)
Mar 29 2024, 9:08 AM
Unknown Object (File)
Mar 25 2024, 4:04 AM
Unknown Object (File)
Feb 25 2024, 2:49 AM
Unknown Object (File)
Feb 19 2024, 10:29 AM
Unknown Object (File)
Jan 31 2024, 8:40 AM
Unknown Object (File)
Jan 28 2024, 8:47 PM
Subscribers

Details

Summary

The reasons:

  1. Get rid of the stubs/quirks with process dethreading, process reparent when the process group leader exits and close to this problems on wait(), waitpid(), etc.
  2. Reuse our kernel code instead of writing excessive thread managment routines in Linuxulator.

Implementation details:

  1. The thread is created via kern_thr_new() in the clone() call with the CLONE_THREAD parameter. Thus, everything else is a process.
  2. The test that the process has a threads is done via P_HADTHREADS bit p_flag of struct proc.
  3. Per thread emulator state data structure is now located in the struct thread and freed in the thread_dtor() hook. Mandatory holdig of the p_mtx required when referencing emuldata from the other threads.
  4. PID mangling has changed. Now Linux pid is the native tid and Linux tgid is the native pid, with the exception of the first thread in the process where tid and pid are one and the same.

Ugliness:

In case when the Linux thread is the initial thread in the thread
group thread id is equal to the process id. Glibc depends on this
magic (assert in pthread_getattr_np.c). So for system calls that
take thread id as a parameter we should use the special method
to reference struct thread.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dchagin retitled this revision from to Switch linuxulator to use the native 1:1 threads..
dchagin updated this object.

So, after discarding the D1038 change rework D1039: remove sv_thread_detach.
TODO: call linux_thread_detach() from proc_exec handler.

Fix sched* locking changes.

yes! Linux kernel does not do any wakeups by child_tid at exec() path.
so, remove thread_detach() from proc_exec().

linux_common_execve() fixed. Other threads destroyred before do_execve() call.

remove experimental code, set sv_thread_detach.

This revision was automatically updated to reflect the committed changes.