Skip to content

Commit

Permalink
graphics: in smp sched_lock is not enough to prevent preemption
Browse files Browse the repository at this point in the history
Signed-off-by: hujun5 <[email protected]>
  • Loading branch information
hujun260 committed Jul 26, 2023
1 parent 02153a2 commit 284712d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions graphics/nxterm/nxterm_kbdin.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static void nxterm_pollnotify(FAR struct nxterm_state_s *priv,
ssize_t nxterm_read(FAR struct file *filep, FAR char *buffer, size_t len)
{
FAR struct nxterm_state_s *priv;
irqstate_t flags;
ssize_t nread;
char ch;
int ret;
Expand Down Expand Up @@ -128,6 +129,7 @@ ssize_t nxterm_read(FAR struct file *filep, FAR char *buffer, size_t len)
* to wake us up.
*/

flags = enter_critical_section();
sched_lock();
priv->nwaiters++;
nxmutex_unlock(&priv->lock);
Expand All @@ -145,6 +147,7 @@ ssize_t nxterm_read(FAR struct file *filep, FAR char *buffer, size_t len)

priv->nwaiters--;
sched_unlock();
leave_critical_section(flags);

/* Did we successfully get the waitsem? */

Expand Down

0 comments on commit 284712d

Please sign in to comment.