Home > OS >  For multi-core CPU, the Linux kernel problem of time delay of create a thread
For multi-core CPU, the Linux kernel problem of time delay of create a thread

Time:11-20

As follows, the kernel device initialization time to create and run a thread cameraout_detect_thread () :
Cameraout_detect_task=kthread_run (cameraout_detect_thread s_ctrl, "msm_sensor: camera - out");
Then the poll in the thread function monitoring, every 1 s read a register values:
Static int cameraout_detect_thread (void * data)
{
Int rc=0;
int i;
. .

Struct sched_param param={. Sched_priority=6};
Sched_setscheduler (current, SCHED_RR, & amp; Param);
. .
//start polling
while (! Kthread_should_stop ()) {
Msleep (1000);//once every 1 s delay

Mutex_lock (& amp; Cameraout_detect_mutex);

Rc=sensor_i2c_client - & gt; I2c_func_tbl - & gt; I2c_read (
Sensor_i2c_client, 0 xa0,
& Cur_plug_status MSM_CAMERA_I2C_BYTE_DATA);
Pr_err (" zjy cur_status: 0 x % x, last_status: 0 x % x \ n ", cur_plug_status, last_plug_status);
. .
Mutex_unlock (& amp; Cameraout_detect_mutex);
}

return 0;
}
Key code as above, an infinite loop in the thread, then every loop execution msleep (1000), namely planning intervals of 1 s execution time, but according to the results of the final printed seemingly every 1 s to perform the four cycle, the following


For using CPU 4 nuclear 8 threads, guess whether because of thread in each kernel in the independent running? What method can prevent?
  • Related