Skip to content

drivers/video/vnc: Replace direct semcount access with nxsem_get_value #16222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions drivers/video/vnc/vnc_updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ static void vnc_sem_debug(FAR struct vnc_session_s *session,
nqueued = sq_count(&session->updqueue);
nfree = sq_count(&session->updfree);

freesem = session->freesem.semcount;
queuesem = session->queuesem.semcount;
nxsem_get_value(&session->freesem, &freesem);
nxsem_get_value(&session->queuesem, &queuesem);

freecount = freesem > 0 ? freesem : 0;
queuecount = queuesem > 0 ? queuesem : 0;
Expand Down Expand Up @@ -225,6 +225,7 @@ static void vnc_free_update(FAR struct vnc_session_s *session,
FAR struct vnc_fbupdate_s *update)
{
irqstate_t flags;
int sval;

/* Reserve one element from the free list. Lock the scheduler to assure
* that the sq_addlast() and the nxsem_post() are atomic.
Expand All @@ -243,7 +244,9 @@ static void vnc_free_update(FAR struct vnc_session_s *session,

leave_critical_section(flags);
vnc_sem_debug(session, "After free", 0);
DEBUGASSERT(session->freesem.semcount <= CONFIG_VNCSERVER_NUPDATES);

DEBUGASSERT(nxsem_get_value(&session->freesem, &sval) == 0 &&
sval <= CONFIG_VNCSERVER_NUPDATES);
}

/****************************************************************************
Expand Down Expand Up @@ -322,6 +325,7 @@ static void vnc_add_queue(FAR struct vnc_session_s *session,
FAR struct vnc_fbupdate_s *rect)
{
irqstate_t flags;
int sval;

/* Lock the scheduler to assure that the sq_addlast() and the nxsem_post()
* are atomic.
Expand All @@ -342,7 +346,9 @@ static void vnc_add_queue(FAR struct vnc_session_s *session,

leave_critical_section(flags);
vnc_sem_debug(session, "After add", 0);
DEBUGASSERT(session->queuesem.semcount <= CONFIG_VNCSERVER_NUPDATES);

DEBUGASSERT(nxsem_get_value(&session->queuesem, &sval) == 0 &&
sval <= CONFIG_VNCSERVER_NUPDATES);
}

/****************************************************************************
Expand Down
Loading