sched/wqueue: Fix windows compilation errors.
This commit fixed windows compilation errors `struct lp_wqueue_s/hp_wqueue_s has an illegal zero-sized array`. Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
parent
025af9d281
commit
a0aa654c70
3 changed files with 20 additions and 9 deletions
|
|
@ -80,16 +80,16 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue, bool sync,
|
||||||
{
|
{
|
||||||
int wndx;
|
int wndx;
|
||||||
pid_t pid = nxsched_gettid();
|
pid_t pid = nxsched_gettid();
|
||||||
|
FAR struct kworker_s *worker = wq_get_worker(wqueue);
|
||||||
|
|
||||||
/* Wait until the worker thread finished the work. */
|
/* Wait until the worker thread finished the work. */
|
||||||
|
|
||||||
for (wndx = 0; wndx < wqueue->nthreads; wndx++)
|
for (wndx = 0; wndx < wqueue->nthreads; wndx++)
|
||||||
{
|
{
|
||||||
if (wqueue->worker[wndx].work == work &&
|
if (worker[wndx].work == work && worker[wndx].pid != pid)
|
||||||
wqueue->worker[wndx].pid != pid)
|
|
||||||
{
|
{
|
||||||
wqueue->worker[wndx].wait_count++;
|
worker[wndx].wait_count++;
|
||||||
sync_wait = &wqueue->worker[wndx].wait;
|
sync_wait = &worker[wndx].wait;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -306,6 +306,7 @@ static int work_thread_create(FAR const char *name, int priority,
|
||||||
FAR void *stack_addr, int stack_size,
|
FAR void *stack_addr, int stack_size,
|
||||||
FAR struct kwork_wqueue_s *wqueue)
|
FAR struct kwork_wqueue_s *wqueue)
|
||||||
{
|
{
|
||||||
|
FAR struct kworker_s *worker = wq_get_worker(wqueue);
|
||||||
FAR char *argv[3];
|
FAR char *argv[3];
|
||||||
char arg0[32];
|
char arg0[32];
|
||||||
char arg1[32];
|
char arg1[32];
|
||||||
|
|
@ -320,10 +321,10 @@ static int work_thread_create(FAR const char *name, int priority,
|
||||||
|
|
||||||
for (wndx = 0; wndx < wqueue->nthreads; wndx++)
|
for (wndx = 0; wndx < wqueue->nthreads; wndx++)
|
||||||
{
|
{
|
||||||
nxsem_init(&wqueue->worker[wndx].wait, 0, 0);
|
nxsem_init(&worker[wndx].wait, 0, 0);
|
||||||
|
|
||||||
snprintf(arg0, sizeof(arg0), "%p", wqueue);
|
snprintf(arg0, sizeof(arg0), "%p", wqueue);
|
||||||
snprintf(arg1, sizeof(arg1), "%p", &wqueue->worker[wndx]);
|
snprintf(arg1, sizeof(arg1), "%p", &worker[wndx]);
|
||||||
argv[0] = arg0;
|
argv[0] = arg0;
|
||||||
argv[1] = arg1;
|
argv[1] = arg1;
|
||||||
argv[2] = NULL;
|
argv[2] = NULL;
|
||||||
|
|
@ -339,7 +340,7 @@ static int work_thread_create(FAR const char *name, int priority,
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
wqueue->worker[wndx].pid = pid;
|
worker[wndx].pid = pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
|
|
@ -504,6 +505,7 @@ int work_queue_free(FAR struct kwork_wqueue_s *wqueue)
|
||||||
|
|
||||||
int work_queue_priority_wq(FAR struct kwork_wqueue_s *wqueue)
|
int work_queue_priority_wq(FAR struct kwork_wqueue_s *wqueue)
|
||||||
{
|
{
|
||||||
|
FAR struct kworker_s *worker;
|
||||||
FAR struct tcb_s *tcb;
|
FAR struct tcb_s *tcb;
|
||||||
|
|
||||||
if (wqueue == NULL)
|
if (wqueue == NULL)
|
||||||
|
|
@ -513,7 +515,10 @@ int work_queue_priority_wq(FAR struct kwork_wqueue_s *wqueue)
|
||||||
|
|
||||||
/* Find for the TCB associated with matching PID */
|
/* Find for the TCB associated with matching PID */
|
||||||
|
|
||||||
tcb = nxsched_get_tcb(wqueue->worker[0].pid);
|
worker = wq_get_worker(wqueue);
|
||||||
|
|
||||||
|
tcb = nxsched_get_tcb(worker[0].pid);
|
||||||
|
|
||||||
if (!tcb)
|
if (!tcb)
|
||||||
{
|
{
|
||||||
return -ESRCH;
|
return -ESRCH;
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,13 @@
|
||||||
#define HPWORKNAME "hpwork"
|
#define HPWORKNAME "hpwork"
|
||||||
#define LPWORKNAME "lpwork"
|
#define LPWORKNAME "lpwork"
|
||||||
|
|
||||||
|
/* Get the worker structure from the work queue.
|
||||||
|
* This function requires the workers are located next to the wqueue.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define wq_get_worker(wq) \
|
||||||
|
(FAR struct kworker_s *)((FAR char *)(wq) + sizeof(struct kwork_wqueue_s))
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Type Definitions
|
* Public Type Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
@ -74,7 +81,6 @@ struct kwork_wqueue_s
|
||||||
uint8_t nthreads; /* Number of worker threads */
|
uint8_t nthreads; /* Number of worker threads */
|
||||||
bool exit; /* A flag to request the thread to exit */
|
bool exit; /* A flag to request the thread to exit */
|
||||||
struct wdog_s timer; /* Timer to pending. */
|
struct wdog_s timer; /* Timer to pending. */
|
||||||
struct kworker_s worker[0]; /* Describes a worker thread */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This structure defines the state of one high-priority work queue. This
|
/* This structure defines the state of one high-priority work queue. This
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue