LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 07-23-2008, 11:53 PM   #1
ashok449
Member
 
Registered: Sep 2007
Location: noida
Distribution: suse
Posts: 63

Rep: Reputation: 16
kthreads scheduling


Dear All,

I'm tryinng to use kthreads, but kthread using 100% CPU time and later on it goes on to halt state.

How do I schedule kthreads?

Code:
static struct task_struct *test1_task;

test1_task = kthread_run(test1_thread, NULL,  "TEST1_THREAD");

int test1_thread(void *unused1)
{ while(1)
        {
        printk(KERN_ALERT "test1 thread\n");
         }
        return 0;
}

Thanks all in advance ...
 
Old 07-24-2008, 06:31 AM   #2
storkus
Member
 
Registered: Jun 2008
Location: Phoenix, Arizona, USA
Distribution: Slackware
Posts: 329

Rep: Reputation: 51
It's been a while since I've written code (hope to fix that soon) but your statement "while(1)" will loop forever because its testing a constant,
if I'm reading this right. I hope that's just a typo here and not in your actual code. Otherwise, I'd say you were writing something for a corewar!

Mike
 
Old 07-24-2008, 07:58 AM   #3
ashok449
Member
 
Registered: Sep 2007
Location: noida
Distribution: suse
Posts: 63

Original Poster
Rep: Reputation: 16
here I'm using while(1) because I wanna use my thread function all the time.

as its taking all of my CPU time, how do I schedule this ?
 
Old 07-24-2008, 09:02 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Look at other kernel threads.

In modern Linuxes, kernel threads can be "interruptible," but they have to request to be so.

Kernel threads, since they are "part of the kernel," do have a pre-eminent and privileged position in the grand scheme of things. You have created a kernel thread that never yields, cannot be interrupted, and never ends. Naturally, the dispatcher dispatches nothing else.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scheduling JUbuntu Linux - Newbie 2 03-21-2008 04:58 PM
Scheduling sleepykit Mandriva 4 02-24-2007 09:01 PM
Scheduling in Linux asurya Linux - General 5 08-31-2005 08:34 AM
scheduling again nautilus_1987 Linux - Software 2 07-04-2003 07:53 AM
java with kthreads model shameless Programming 5 06-21-2002 07:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration