Commit Graph

44 Commits

Author SHA1 Message Date
Jérôme Duval
301d9851fe fix change in revision 20162, the path was left out
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20186 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-20 20:27:23 +00:00
Travis Geiselbrecht
040e5e50f1 fix a kernel clobberer that showed up when running gcc. Was able to successfully build a hello world app with gcc after this.
The kernel arg logic was faulty, and wasn't using strlcpy properly (which returns the size of the src string, not the remaining size). Replaced it with a simpler, but less efficient series of strlcat()s.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20162 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-19 06:57:38 +00:00
Axel Dörfler
4d634ea794 Prevented the somewhat broken env copying code from clobbering memory it shouldn't really touch.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20127 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-02-13 06:42:58 +00:00
Axel Dörfler
2e27874523 * wait_for_child() now behaves correctly when waiting for children of a specific
process group. This fixes bug #996.
* As a result, the process group stuff and wait_for_child() got much simpler;
  get_death_entry() and update_wait_for_any() could go away completely.
* If a team goes away, all of its children are now "reparented" to the kernel team,
  instead of the team's parent - this follows common implementations (and POSIX if
  I understand it correctly), but not BeOS anymore. The OpenGroup Base says this
  about this topic: "If a parent process terminates without waiting for all of its
  child processes to terminate, the remaining child processes shall be assigned a
  new parent process ID corresponding to an implementation-defined system process."
* We wait too long in wait_test_4 which at least puts us on par with Linux; see
  comment in _user_setpgid().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20010 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-29 15:33:31 +00:00
Axel Dörfler
268fe0f839 * wait_for_child() now checks if the team has any children to wait for, and returns
ECHILD in case it doesn't. This fixes bug #995.
* Added a TODO item for solving bug #996.
* wait_for_child() did not release the team lock and restore interrupts in case
  the child you wanted to wait for didn't exist...
* with child > 0, wait_for_child() will now check if its really a child of yours,
  and not just in the same process group.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19993 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-28 14:31:42 +00:00
Axel Dörfler
f4972679f7 * team::args was not correctly initialized in create_team_struct()
* even worse, in case of fork(), it was never initialized.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19799 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-14 23:22:49 +00:00
Axel Dörfler
b129e4cee1 Another kernel bug less:
* send_signal_etc() (among others) used team::main_thread in an unsafe way; it is
  possible for a team to be part of the team list and a group without having
  a main thread very early in its creation process.
* Replaced most occurences of team->main_thread->id with team->id since the team
  always inherits the ID of its main thread in Haiku for quite some time now.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19781 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-12 22:54:21 +00:00
Axel Dörfler
8fc075ac5c * There was no reason to copy the "userland calls exit_thread()" stub with interrupts
turned off - accessing userland memory. Now, arch_thread_enter_userspace() does that
  job, and as a result, may also fail.
* dump_thread() now directly prints the info of the current thread when used without
  argument (rather than iterating the thread list to look for the current thread).
* If arch_thread_init_tls() fails upon thread creation, the function will now return
  an error.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19775 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-12 18:26:32 +00:00
Axel Dörfler
cdcb059571 * Renamed get_team_death_entry() to team_get_death_entry() and make it available
to other kernel components.
* wait_for_thread_etc() will now search the team's death entries in case the
  thread is already gone; also resume_thread() is now done later, and its return
  code will no longer matter (as we already have our death entry, no matter if
  the thread is gone now or not).
* The fibo_load_image test now works as expected (only tested with low numbers
  yet, though - the mean testing comes later (first comes functionality) :-))


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19758 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-01-09 23:58:59 +00:00
Axel Dörfler
da758f9fce * team::args is now correctly filled in.
* the member will now also be shown when dumping a team.
* minor cleanup: moved fill_team_info() into the private functions part of the file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19551 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-12-18 12:56:27 +00:00
Axel Dörfler
45894e1088 Minor cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19039 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-10-10 22:39:57 +00:00
Axel Dörfler
d9766fe30b * Changed team_get_process_group_locked() to have a session parameter instead
of a team to avoid confusion. It now also accepts a NULL session pointer in
  which case the actual group's session doesn't matter.
* Fixed the race condition in send_signal_etc() that could allow accessing an
  invalid team pointer.
* Jerome's earlier change already fixed bug #841, and this also fixed bug #855.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18941 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-26 12:51:59 +00:00
Jérôme Duval
65afc3a011 also dump group and session ids
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18887 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-09-19 09:40:09 +00:00
Axel Dörfler
be0e738496 * send_signal_etc() now handles a pid_t of -1 specially, but not yet really correct
(that was part of the problem of bug #702).
* Fixed send_signal_etc() when you called it with a pid_t of zero: the signals should
  go to all teams in the calling team's group, not only to the team (for -1, we do
  the same for now).
* Made team_get_process_group_locked() public, and rewrote send_signal_etc() to use
  it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18684 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-29 01:41:16 +00:00
Axel Dörfler
f8b41f8219 Moved functions around, so that the static private functions are at the top.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18623 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-24 23:41:54 +00:00
Axel Dörfler
6961cdf6f2 Process groups are no longer searched via their team/session, but by using a separate
hash. This also allows them to stay valid after the group leader died when there are
other teams left in it. This closes bug #1.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18622 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-24 22:58:48 +00:00
Axel Dörfler
3e975f9210 Minor cleanup; renamed some global static variables to match our style guide.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18621 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-24 22:29:54 +00:00
Axel Dörfler
2b6a368811 wait_for_child() could eventually hang until another team exited (or forever if
it waited for a specific child), as B_RELEASE_ALL opened up a race condition between
looking for an existing death entry, and waiting for the dead children semaphore.
Now we're counting all waiting threads for teams and groups separately.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18543 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-20 21:27:12 +00:00
Stefano Ceccherini
0ce93ee730 the signal block mask is inherited by the child process on fork()
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18532 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-18 08:26:37 +00:00
Axel Dörfler
73a56f1bac * wait_for_child() (the backend to waitpid()) did not work correctly in case you
wanted to wait for a specific child; it always assumed you had specified WNOHANG.
  This fixes the bug the fork_3-1 and fork_4-1 test applications reported. 3-1 still
  sometimes fails, but that's a different problem (to be solved later).
* Also, it could return B_BAD_THREAD_ID instead of the expected ECHILD (for waitpid()).
* There was a race condition between testing for a thread, and checking its death
  entry.
* wait_for_child() can now be interrupted in case it has to wait.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18528 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-17 21:40:55 +00:00
Axel Dörfler
4e26bc08b8 user_copy_strings_array() no longer puts 2k on the stack, but allocates a 16k
buffer to allow safe access of the user provided string - maybe we should
introduce a user_strdup() instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17960 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-06-29 15:23:34 +00:00
Axel Dörfler
c8882988b7 The kernel's struct team now has a field to remember where the arguments of a
running team to be able to fill in the team_info::args field. Currently, only
the path is stored, there, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17646 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-30 00:21:22 +00:00
Axel Dörfler
2bbc6df8dc * The kernel now remembers the signal that killed a thread (if it was killed).
* As suggested by Korli, the signal is now encoded in the "reason" field of
  wait_for_child().
* waitpid() now sets the status passed in so that the signal can be read out
  (but it still doesn't do it's full job).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17338 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-05-05 15:33:34 +00:00
Axel Dörfler
af3e5cd947 Renamed our runtime loader from rld.so to runtime_loader, and moved it into beos/system/.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16936 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-03-30 18:08:51 +00:00
Axel Dörfler
d608540b67 Separated vm_address_space.h from vm.h.
Some more cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15614 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-20 15:54:45 +00:00
Axel Dörfler
96e01a27bf * Merged vm_virtual_map with vm_address_space - there was no reason to have
them apart (this even saves a pointer from vm_virtual_map to its address space)
* aspace -> address_space
* vm_create_address_space() did not check if creating the semaphore succeeded
* Removed team::kaspace - was not really needed (introduced a new vm_kernel_address_space()
  function that doesn't grab a reference to the address space)
* Removed vm_address_space::name - it was just a copy of the team name, anyway,
  and there is always only one address space per team
* Removed aspace_id - the address space is now using the team_id
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15609 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-12-20 13:29:11 +00:00
Axel Dörfler
2e8eec5722 Now also prints the parent's team ID as part of the team info.
No longer uses dprintf() in the kernel debugger.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14631 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-02 10:43:30 +00:00
Axel Dörfler
05a7818c85 Removed the "list all team" functionality from the debugger command "team", and
moved it into the new command "teams". Now also lists the parent team.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14630 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-11-02 10:38:28 +00:00
Axel Dörfler
6cd505cee7 Changed the boot procedure a bit.
Extracted scheduler_init() from start_scheduler() (which is now called scheduler_start()).
Moved scheduler related function prototypes from thread.h to the new scheduler.h.
Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14518 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-10-25 16:59:12 +00:00
Axel Dörfler
a4c373515e When a team died, only the time of its children were added to its parent
dead children time counters - not its own time.
Moved time calculation to team_remove_team().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14464 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-10-21 00:15:17 +00:00
Axel Dörfler
7dc1c65f2f Improved "team" debugger command: it will no longer crash on the kernel team, it
will no longer use vm_get_kernel_aspace() (which acquired a semaphore) and it now
accepts decimal team IDs as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14307 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-10-06 08:36:37 +00:00
Axel Dörfler
08da6fccdd Introduced a sane concept of ownership for the team_args structure: now load_image_etc()
and exec_team() have an additional "kernel" argument and will copy the arguments
themselves (or rather, delegate that to create_team_arg()).
When team_create_thread_start() is called, it will take over ownership and is
responsible for deleting it - this also fixed a memory leak in case the user
stack area couldn't be created.
Also changed comment after exit_thread(): since this call only delivers a signal, the
code after it will still get executed.
This fixes the crashing symptom of bug #50.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14303 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-10-05 15:32:48 +00:00
Axel Dörfler
d86d4063b0 thread_create_thread_start() is a thread_func and therefore returns int32 not status_t
(that's what our headers say).
Some style fixes in signal.c.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14192 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-09-16 12:52:59 +00:00
Jérôme Duval
3f84430938 added a trace and changed err type in team_create_thread_start()
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14180 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-09-13 15:44:30 +00:00
Axel Dörfler
f26e4a1c98 Made hash functions able to deal with keys with negative numbers.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14066 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-08-26 02:02:33 +00:00
Axel Dörfler
06ae92cd04 Maybe it's better to free the team resources after notifying the watchers;
since the hooks are called in the context of the team.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13903 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-08-05 10:27:08 +00:00
Ingo Weinhold
7d11acca6d Spotted by Axel: If the caller of a load_image_etc() was waiting for the new team to be loaded, but the team died before finishing loading we were notifying the caller only in case the team had already more than one thread.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13900 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-08-04 22:45:04 +00:00
Axel Dörfler
0d299e8a4b The team watching mechanism now works as intended.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13892 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-08-03 16:57:40 +00:00
Axel Dörfler
5159717538 team_delete_team() should have called delete_team_struct() instead of just
freeing the team - it leaked dead children semaphores and death entries;
waiting for a specific team could not have worked before.
Fixed delete_team_struct(), it did not correctly free the death list (would
have accessed freed memory).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13890 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-08-03 12:42:01 +00:00
Axel Dörfler
99c566f6c9 Added a team watching mechanism in the kernel, not yet tested (but at least doesn't cause any harm yet :-)).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13888 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-08-03 12:00:42 +00:00
Ingo Weinhold
aeaa4a21a4 It's considered rude to try killing the kernel team.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13705 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-07-16 23:38:07 +00:00
Axel Dörfler
229b2db028 cache_node_launched() is now called later, so that the environment will
be the same for both ways (via load_image() and exec*()).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13112 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-06-14 11:15:05 +00:00
Axel Dörfler
24b2daf33d Slightly improved debug output.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12888 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-05-29 12:53:56 +00:00
Axel Dörfler
2d690920ac Renamed system/core to system/kernel.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12360 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-04-13 13:22:10 +00:00