equal
deleted
inserted
replaced
355 |
355 |
356 int ec_master_thread_start(ec_master_t *master /**< EtherCAT master */) |
356 int ec_master_thread_start(ec_master_t *master /**< EtherCAT master */) |
357 { |
357 { |
358 init_completion(&master->thread_exit); |
358 init_completion(&master->thread_exit); |
359 |
359 |
|
360 EC_INFO("Starting master thread.\n"); |
360 if (!(master->thread_id = |
361 if (!(master->thread_id = |
361 kernel_thread(ec_master_thread, master, CLONE_KERNEL))) |
362 kernel_thread(ec_master_thread, master, CLONE_KERNEL))) |
362 return -1; |
363 return -1; |
363 |
364 |
364 return 0; |
365 return 0; |
373 void ec_master_thread_stop(ec_master_t *master /**< EtherCAT master */) |
374 void ec_master_thread_stop(ec_master_t *master /**< EtherCAT master */) |
374 { |
375 { |
375 if (master->thread_id) { |
376 if (master->thread_id) { |
376 kill_proc(master->thread_id, SIGTERM, 1); |
377 kill_proc(master->thread_id, SIGTERM, 1); |
377 wait_for_completion(&master->thread_exit); |
378 wait_for_completion(&master->thread_exit); |
378 EC_DBG("Master thread exited.\n"); |
379 EC_INFO("Master thread exited.\n"); |
379 } |
380 } |
380 } |
381 } |
381 |
382 |
382 /*****************************************************************************/ |
383 /*****************************************************************************/ |
383 |
384 |
837 |
838 |
838 set_current_state(TASK_INTERRUPTIBLE); |
839 set_current_state(TASK_INTERRUPTIBLE); |
839 schedule_timeout(1); |
840 schedule_timeout(1); |
840 } |
841 } |
841 |
842 |
842 EC_INFO("Master thread exiting.\n"); |
|
843 master->thread_id = 0; |
843 master->thread_id = 0; |
844 complete_and_exit(&master->thread_exit, 0); |
844 complete_and_exit(&master->thread_exit, 0); |
845 } |
845 } |
846 |
846 |
847 /*****************************************************************************/ |
847 /*****************************************************************************/ |