Re: system calls in kernel timer callback functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 25, 2003 at 06:01:59PM +0100, Obermeier Markus ICM MP PD TS wrote:
|Hi,
|
|I have developped a small kernel module. It schedules a regular timer calling the timeout function.
|In this timeout function I would like to open the file /proc/net/dev from proc-filesystem. 

you shouldn't!!!!


|If I do,
|the kernel crashes. 

Because you shouldn't issue a sys_* from kernel_space!!!!!
(sometimes you can [by changin segment limitis{if interested looks at 
 the khttpd source}] but is not your case)

|How do I make system calls in timer callback function.

Please Avoid!


|static void hello_timeout(unsigned long ptr) {
|   printk(KERN_ALERT "Timeout %u\n",num);
|   if (last_call) del_timer(&list);
|   else {
|     num++;
|     init_timer(&list);
|     list.function = hello_timeout;
|     list.data = 0;
|     list.expires = jiffies + HZ;
|     add_timer(&list);
|     if ((fd=sys_open("/proc/net/dev",O_RDONLY, 0x444)) == 0) {
      ^
      |
+-----+
|
|
+-------- here is a source of pain ;)


if you want to read those infos from kernel space look at the
dev_get_info function (located  in net/core/dev.c)

Have fun!!



-- 

Daniele.




"I could have made money this way, and perhaps amused myself writing code. 
But I knew that at the end of my career, I would look back on years of 
building walls to divide people, and feel I had spent my life making the 
world a worse place."                               
                                                          Richard Stallman


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux