LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 09-19-2009, 09:13 AM   #1
cricketlong
Member
 
Registered: Dec 2008
Posts: 52

Rep: Reputation: 15
Question How to avoid kernel blocking while running a module in uclinux2.4?


My intention:
running a music playing module and allow the kernel to do any other things at the same time.

I use the section of C code bellow for kt module:

Code:
int kt_handler(unsigned long data)
{
    int i, j;
    for(i = 0;i < 10000;i++)
        for(j = 0;j < 10000;j++){}
    complete(&kt_cpl);
    return 0;
}

int kt_read(struct inode *inode, struct file *filp, char *buf, unsigned long cmd)
{
    kernel_thread(kt_handler, NULL, CLONE_VM|SIGCHLD);
    printk("Waiting for completion......\n");
    wait_for_completion(&kt_cpl);
    printk("Completed. Continue......\n");
    return 0;
}
I open the module with the following line:
Code:
open("/dev/kt", O_RDWR);
output:
Waiting for completion......
(stops here for more than 5 seconds)
Completed. Continue......
 
Old 09-20-2009, 02:33 AM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,094

Rep: Reputation: 104Reputation: 104
i am just gussing but try
changing
Code:
 for(j = 0;j < 10000;j++){}
to
Code:
 for(j = 0;j < 10000;j++){usleep(10);}
please try and tell me the result
 
Old 09-20-2009, 07:55 AM   #3
cricketlong
Member
 
Registered: Dec 2008
Posts: 52

Original Poster
Rep: Reputation: 15
it seems that usleep is not available in a module

I compiled and got error bellow:
drivers/char/char.o(.text+0xa028): In function `kt_handler':
: undefined reference to `usleep'
make[1]: *** [linux] Error 1
make[1]: Leaving directory `/root/uClinux-dist/linux-2.4.x'
make: *** [linux] Error 1
 
Old 09-26-2009, 10:59 PM   #4
cricketlong
Member
 
Registered: Dec 2008
Posts: 52

Original Poster
Rep: Reputation: 15
Can any body help me?
 
Old 09-26-2009, 11:27 PM   #5
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,094

Rep: Reputation: 104Reputation: 104
forums are dead right now
 
Old 09-27-2009, 01:58 AM   #6
virtualCoder
Member
 
Registered: Sep 2007
Distribution: Ubuntu
Posts: 33

Rep: Reputation: 15
If you are trying to use usleep, did you add: #include <unistd.h>
If I understood your question correctly, you are trying to sleep for 5 secs, then you can also use:
#include <unistd.h>
unsigned int sleep(unsigned int seconds);

So sleep(5); // sleep for 5 seconds.
 
Old 09-27-2009, 08:52 PM   #7
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: washington U.S.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,094

Rep: Reputation: 104Reputation: 104
Quote:
Originally Posted by virtualCoder View Post
If you are trying to use usleep, did you add: #include <unistd.h>
If I understood your question correctly, you are trying to sleep for 5 secs, then you can also use:
#include <unistd.h>
unsigned int sleep(unsigned int seconds);

So sleep(5); // sleep for 5 seconds.
no its a linker error so adding include files wont help
 
Old 09-28-2009, 12:57 AM   #8
cricketlong
Member
 
Registered: Dec 2008
Posts: 52

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by smeezekitty View Post
no its a linker error so adding include files wont help
agree, include files can only make affection during compiling.
 
  


Reply

Tags
arm7, multitasking


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to avoid write file from a kernel module xiaozhe2000 Linux - Kernel 3 09-17-2008 07:09 AM
problem running kernel module jopu Linux - Newbie 2 03-14-2007 11:58 PM
how to avoid a module of being loaded? maginotjr Slackware 2 08-11-2005 08:55 PM
compile module for running kernel maenho Linux - Software 5 06-27-2005 01:44 PM
Kernel Module compilation and running imransadat Programming 3 03-04-2005 06:56 AM


All times are GMT -5. The time now is 03:21 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration