Date: Sun, 7 Jan 2001 21:11:59 -0600 From: Robert Lipe <robertlipe@usa.net> To: freebsd-hackers@FreeBSD.ORG Subject: kthread_exit & zombification Message-ID: <20010107211159.C1400@rjlhome.sco.com>
next in thread | raw e-mail | index | archive | help
Hi, Gang. In 4.1.1, I have a pretty simple need for a kernel thread or two, but I'm having problems with kthread_exit(). The problem is that the thread goes zombie after I kthread_exit in it, but it never gets reaped. Since I'm doing this during a MOD_UNLOAD phase, if I happen to do a `ps -ax' after the module has been unmapped, a panic results becuase it's trying to get the lwp name and wchan string from what is now unmapped memory. But that's a secondary problem; the primary one is that I am missing whatever it takes to get a ticket for the resulting kernel thread to go to Byte Heaven. After a couple of load/unload cycles, I see: $ ps -alx | grep mem 0 357 0 2 0 0 0 0 - ZL ?? 0:00.00 (udi_memd) 0 360 0 2 0 0 0 0 - ZL ?? 0:00.00 (udi_memd) 0 920 0 2 0 0 0 0 - ZL ?? 0:00.00 (udi_memd) 0 954 0 0 0 0 0 0 udi_os SL ?? 0:00.00 (udi_memd) The creation is pretty simple: if (kthread_create(my_daemon, NULL, &my_thread, "mydaemon")) { printf("kthread_create failed!\n"); } Once the interesting part is stripped away, the daemon itself is texbook: _udi_alloc_daemon(void *arg) { while (!kill_daemon_req) { /* do work */ } wakeup(&_udi_kill_daemon); kthread_exit(0); } And the code that does the teardown looks like: case MOD_UNLOAD: kill_daemon_req = TRUE; /* poke the daemon to awaken it's 'work' loop */ ... tsleep(&_udi_kill_daemon, PZERO, "udiallocdeath", 0); I can see the interlocks happening with the tsleep/wakeup, so I know we're not unloading prematurely. There aren't many users of the kthread facilities in the kernel and since they don't seem to be in modules, the teardown case might have been skipped. What am I missing? Thanx, RJL To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010107211159.C1400>