Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8412277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:38:04+00:00 2026-06-10T00:38:04+00:00

In my own kernel module, I am trying to init a kthread within an

  • 0

In my own kernel module, I am trying to init a kthread within an interrupt handler function.

in the global scope I have:

static struct task_struct *thread1;

the function handler of the irq is:

static irqreturn_t* func_irq_handler (int irq, void *dev_id)
{   
    printk("irq handler ... \n");
    thread1 = kthread_create(thread_function,NULL,"my_thread");
    if ((thread1)) {
        printk(KERN_INFO "%s\n" , __FUNCTION__);
    }
    return IRQ_HANDLED;
}

and the thread function is:

static thread_function(void)
{
    unsigned long j1=jiffies+20000;
    int delay = 60*HZ;
    printk("%s \n",__FUNCTION__);

    while (time_before(jiffies,j1)) {
        schedule();
        printk(KERN_INFO "after schedule\n");
    }
}

the request_irq looks like this:

request_irq(irq,func_irq_handler,IRQF_TRIGGER_HIGH | IRQF_TRIGGER_RISING ,"test_irq",(void*)&my_miscdev);

why do I get this error:

BUG: scheduling while atomic: swapper
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:38:06+00:00Added an answer on June 10, 2026 at 12:38 am

    I would imagine that creating a thread requires interaction with the thread scheduler, which is not allowed at interrupt/atomic context.

    A better approach would be to create your kernel thread elsewhere, and queue interrupt request processing to it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a kernel module which forms its own packet at ip level
I have a kernel module in which I deal with USB devices. It happens
im trying to make my own kernel.... my kernel is loaded through grub...which i
How does the kernel cope with the schedule() function being called from within an
Is there any possibility to access the sys_call_table from my own module for Kernel
I have created my own Perl module. I reference it from file Config.pm. When
I'm writing my own memory allocator. If my notion is right, there is kernel's
I own a video streaming website and currently I just have a simple hit
I have my own installer program which I use to install several applications I
I am creating my own carousel slideshow for images, using Jquery. Currently i have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.