execve() and KSE

Julian Elischer julian at elischer.org
Wed May 19 21:15:38 PDT 2004


What is supposed to happen is that all the execve should stall awaiting
all the other kernel threads to abort/suicide and then it should proceed
with the execve as per normal.
it is possible this doesn't work right.. I haven't tried ti for a LONG
time..

julian

On Thu, 20 May 2004, Tim Robbins wrote:

> What is supposed to happen when a threaded process (linked with libpthread)
> calls execve()?
> 
> The program attached to this message seems to execute "true" correctly, but
> it never returns to the shell I invoked it from. ^T shows it in the state
> "running", and the system load average approaches 1.00:
> 
> load: 0.15  cmd: true 726 [running] 0.00u 0.00s 0% 200k
> load: 0.56  cmd: true 726 [running] 0.00u 0.00s 0% 200k
> load: 0.91  cmd: true 726 [running] 0.00u 0.00s 0% 200k
> 
> However, it's not using any CPU according to %CPU:
> 
> $ ps -Haxo pid,%cpu,mwchan,state,command -p 726
>   PID %CPU MWCHAN STAT COMMAND
>   726  0.0 -      RL+  true
> 
> The system is FreeBSD 5.2-CURRENT/amd64 with a kernel from May 9, and with
> WITNESS and INVARIANTS both turned off. I'll try updating and re-enabling
> the diagnostic options later today.
> 
> Here's the code in question:
> 
> #include <pthread.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> 
> static pthread_cond_t cond;
> 
> void *
> thrstart(void *a)
> {
> 
> 	pthread_cond_wait(&cond, NULL);
> 	if (execl("/usr/bin/true", "true", NULL) < 0)
> 		perror("execl");
> 	return (NULL);
> }
> 
> int
> main(int argc, char *argv[])
> {
> 	void *v;
> 	pthread_t t1;
> 
> 	pthread_cond_init(&cond, NULL);
> 	pthread_create(&t1, NULL, thrstart, NULL);
> 	pthread_cond_broadcast(&cond);
> 	pthread_join(t1, &v);
> 
> 	exit(0);
> }
> _______________________________________________
> freebsd-threads at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-threads
> To unsubscribe, send any mail to "freebsd-threads-unsubscribe at freebsd.org"
> 



More information about the freebsd-threads mailing list