title: scheduling tasks in linux kernel module everyday at a user provided time
body: <p>I am writing a linux kernel module which schedules a task using schedule_delayed_work at a particular time which in turn send a signal to a user space program to do some task.
  What I did is manually given the time in milliseconds (say 5000ms) and changed it to jiffies using "msec to jiffies" function and tested it and worked.</p>
  
  <p>My use case is that the user will give a time (say 5 pm) and the module has to schedule it to send the signal everyday at 5 pm to the user program. I am totally confused in how to calculate the milliseconds from the user given time for everyday basis.</p>
  
  <p>I used workqueue to create a queue and then the task to accomplish and doing the scheduling.</p>
  
  <p>My kernel module:</p>
  
  <pre><code>    static void wq_handler_function(struct work_struct *work);
      static unsigned long delay;
  
      static struct workqueue_struct *my_wq; // my workqueue
      static DECLARE_DELAYED_WORK(my_work, wq_handler_function); //my work/task
  
  
      static void wq_handler_function(struct work_struct *work)
      {
         printk(KERN_DEBUG "handler function called\n");
         if(my_wq)
         {
            /*Do some work like sending signal to user space*/
            schedule_delayed_work(&amp;my_work, delay); /*reschedule after the first scheduled time finished*/
         }
      }
  
      int sig_init_module(void)
      {
         printk(KERN_DEBUG "signal module initiated\n");
         delay = msecs_to_jiffies(5000); //Manually given 5000ms (5 sec) for scheuling
         if(!my_wq)
            my_wq = create_workqueue("my_queue");
  
            if(my_wq)
            {
               schedule_delayed_work(&amp;my_work, delay); /*schedule for the first time while module initiates*/
            }
          return 0;
       }
  
       void sig_cleanup_module(void)
       {
          flush_scheduled_work();
          cancel_delayed_work_sync(&amp;my_work);
  
          flush_workqueue(my_wq);
          destroy_workqueue(my_wq);
  
          printk(KERN_DEBUG "signal module removed\n");
       }
  
       module_init(sig_init_module);
       module_exit(sig_cleanup_module);
  </code></pre>
  
  <p>Kindly help me to have a solution for this. Thanks in advance!!!.</p>