Kernel preemption -- demo does not work

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

 



Hello,

I'm experimenting about kernel preemption. If I understand it
correctly, a process executing a syscall could be preempted by another
process with a higher priority.

I have a simple kernel module with a 10 seconds loop in the
init_module() function. This function should be preemptible because
it's the insmod process in the init_module system call.

But another process with SCHED_FIFO (prio 99) isn't run until the init
function exits.

The code is

    int __init preempt_test_init(void)
    {
        unsigned long end;

        end = jiffies + HZ * 10; /* 10 seconds */

        pr_info("Preempt_count = %d\n", preempt_count());
        while (time_before(jiffies, end));
        pr_info("End\n");
    }

and of the process

    int main(int argc, char *argv[])
    {
        int                     err;
        struct sched_param      parm;
        int                     counter = 0;

        memset(&parm, 0, sizeof (struct sched_param));
        parm.sched_priority = 99;

        err = sched_setscheduler(getpid(), SCHED_FIFO, &parm);
        if (err < 0) {
            perror("Cannot change scheduler");
            return 1;
        }

        while (true) {
            printf("Scheduled, count = %d\n", counter++);
            sleep(1);
        }

        return 0;
    }

Thanks!


Regards,
  Bernhard

--
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