sched_lock refine: remove sched_[un]lock in xxx_waitsample
Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
parent
b2e6d7b9d7
commit
1a65f5ed88
5 changed files with 17 additions and 52 deletions
|
|
@ -357,12 +357,8 @@ static int sam_tsd_waitsample(struct sam_tsd_s *priv,
|
|||
/* Interrupts must be disabled when this is called to (1) prevent posting
|
||||
* of semaphores from interrupt handlers, and (2) to prevent sampled data
|
||||
* from changing until it has been reported.
|
||||
*
|
||||
* In addition, we will also disable pre-emption to prevent other threads
|
||||
* from getting control while we muck with the semaphores.
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Now release the semaphore that manages mutually exclusive access to
|
||||
|
|
@ -408,14 +404,6 @@ errout:
|
|||
*/
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Restore pre-emption. We might get suspended here but that is okay
|
||||
* because we already have our sample. Note: this means that if there
|
||||
* were two threads reading from the touchscreen ADC for some reason, the
|
||||
* data might be read out of order.
|
||||
*/
|
||||
|
||||
sched_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -666,12 +666,14 @@ static int tc_waitsample(struct tc_dev_s *priv,
|
|||
struct tc_sample_s *sample)
|
||||
{
|
||||
int ret;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Pre-emption must be disabled when this is called to prevent sampled
|
||||
* data from changing until it has been reported.
|
||||
/* Interrupts must be disabled when this is called to (1) prevent posting
|
||||
* of semaphores from interrupt handlers, and (2) to prevent sampled data
|
||||
* from changing until it has been reported.
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Now release the mutex that manages mutually exclusive access to
|
||||
* the device structure. This may cause other tasks to become ready to
|
||||
|
|
@ -706,13 +708,12 @@ static int tc_waitsample(struct tc_dev_s *priv,
|
|||
ret = nxmutex_lock(&priv->devlock);
|
||||
|
||||
errout:
|
||||
/* Restore pre-emption. We might get suspended here but that is okay
|
||||
* because we already have our sample. Note: this means that if there
|
||||
* were two threads reading from the touchscreen for some reason, the data
|
||||
* might be read out of order.
|
||||
/* Then re-enable interrupts. We might get interrupt here and there
|
||||
* could be a new sample. But no new threads will run because we still
|
||||
* have pre-emption disabled.
|
||||
*/
|
||||
|
||||
sched_unlock();
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -556,11 +556,12 @@ static int tc_waitsample(struct tc_dev_s *priv,
|
|||
{
|
||||
int ret;
|
||||
|
||||
/* Pre-emption must be disabled when this is called to prevent sampled
|
||||
* data from changing until it has been reported.
|
||||
/* Interrupts must be disabled when this is called to (1) prevent posting
|
||||
* of semaphores from interrupt handlers, and (2) to prevent sampled data
|
||||
* from changing until it has been reported.
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Now release the mutex that manages mutually exclusive access to
|
||||
* the device structure. This may cause other tasks to become ready to
|
||||
|
|
@ -595,13 +596,12 @@ static int tc_waitsample(struct tc_dev_s *priv,
|
|||
ret = nxmutex_lock(&priv->devlock);
|
||||
|
||||
errout:
|
||||
/* Restore pre-emption. We might get suspended here but that is okay
|
||||
* because we already have our sample. Note: this means that if there
|
||||
* were two threads reading from the touchscreen for some reason, the data
|
||||
* might be read out of order.
|
||||
/* Then re-enable interrupts. We might get interrupt here and there
|
||||
* could be a new sample. But no new threads will run because we still
|
||||
* have pre-emption disabled.
|
||||
*/
|
||||
|
||||
sched_unlock();
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1263,12 +1263,8 @@ static int usbhost_waitsample(FAR struct usbhost_state_s *priv,
|
|||
/* Interrupts must be disabled when this is called to (1) prevent posting
|
||||
* of semaphores from interrupt handlers, and (2) to prevent sampled data
|
||||
* from changing until it has been reported.
|
||||
*
|
||||
* In addition, we will also disable pre-emption to prevent other threads
|
||||
* from getting control while we muck with the semaphores.
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Now release the semaphore that manages mutually exclusive access to
|
||||
|
|
@ -1322,14 +1318,6 @@ errout:
|
|||
*/
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Restore pre-emption. We might get suspended here but that is okay
|
||||
* because we already have our sample. Note: this means that if there
|
||||
* were two threads reading from the HIDMOUSE for some reason, the data
|
||||
* might be read out of order.
|
||||
*/
|
||||
|
||||
sched_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -960,12 +960,8 @@ static int usbhost_waitsample(FAR struct usbhost_state_s *priv,
|
|||
/* Interrupts must be disabled when this is called to (1) prevent posting
|
||||
* of semaphores from interrupt handlers, and (2) to prevent sampled data
|
||||
* from changing until it has been reported.
|
||||
*
|
||||
* In addition, we will also disable pre-emption to prevent other threads
|
||||
* from getting control while we muck with the semaphores.
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Now release the semaphore that manages mutually exclusive access to
|
||||
|
|
@ -1019,14 +1015,6 @@ errout:
|
|||
*/
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Restore pre-emption. We might get suspended here but that is okay
|
||||
* because we already have our sample. Note: this means that if there
|
||||
* were two threads reading from the HIDMOUSE for some reason, the data
|
||||
* might be read out of order.
|
||||
*/
|
||||
|
||||
sched_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue