From: mingz <mingz@ele.uri.edu>
To: linux-kernel@vger.kernel.org
Subject: defunc thread?
Date: Tue, 15 Jul 2003 09:54:42 -0400 [thread overview]
Message-ID: <200307150954.42253.mingz@ele.uri.edu> (raw)
I code a smal example about kernel thread. But when I
insmod thrtest.o &
more /proc/testthread
ps aux
then i can see my thread become defunc. if i
insmod (and wait till it return, )
more /proc/testthread,
ps aux,
the thread status is correct. can anybody tell me why? thx
ming
---------------------------------------------------------------------------------
#include <linux/errno.h> /* Miscellaneous error codes */
#include <linux/stddef.h> /* NULL */
#include <linux/slab.h> /* kmalloc() */
#include <linux/module.h> /* EXPORT_SYMBOL */
#include <linux/pci.h>
#include <linux/smp_lock.h>
#include <linux/proc_fs.h>
#include <asm/uaccess.h>
#include <linux/interrupt.h>
DECLARE_WAIT_QUEUE_HEAD(test_wait);
int t_thread(void *startup)
{
int i = 0;
lock_kernel();
daemonize();
current->tty = NULL;
strcpy(current->comm, "testthread");
unlock_kernel();
spin_lock_irq(¤t->sigmask_lock);
sigfillset(¤t->blocked);
recalc_sigpending(current);
spin_unlock_irq(¤t->sigmask_lock);
complete((struct completion *)startup);
printk("test thread up and call complete\n");
interruptible_sleep_on(&test_wait);
printk("thread wake up %d times\n", ++i);
printk("test thread do cleanup work\n");
return 0;
}
int test_read_procmem(char *buf, char **start, off_t offset, int count, int
*eof, void *data)
{
int len = 0;
len += sprintf(buf+len,"test v0.1 Dragonfly, ELE, URI\n");
*eof = 1;
wake_up_interruptible(&test_wait);
return len;
}
static struct completion startup = COMPLETION_INITIALIZER(startup);
int test_init(void)
{
kernel_thread(t_thread, &startup, CLONE_FS | CLONE_FILES | CLONE_SIGNAL);
wait_for_completion(&startup);
create_proc_read_entry("testthread", 0, NULL, test_read_procmem, NULL);
set_current_state (TASK_INTERRUPTIBLE);
schedule_timeout (30*HZ);
__set_current_state (TASK_RUNNING);
return 0;
}
void test_clean(void)
{
remove_proc_entry("helpm", NULL);
}
module_init(test_init);
module_exit(test_clean);
MODULE_DESCRIPTION("Test Thread");
MODULE_LICENSE("GPL");
reply other threads:[~2003-07-15 14:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200307150954.42253.mingz@ele.uri.edu \
--to=mingz@ele.uri.edu \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®