Skip to content

Commit bf3f1db

Browse files
yangao1zzby0
authored andcommitted
ostest/cancel.c: fix busyloop after improving ostest priority
Because the priority of ostest was increased, the priority of the main thread also increased. Newly created threads still used the default priority, causing the parent thread to prematurely cancel the child thread. This resulted in the child thread not being properly garbage collected, leading to a system busy loop. Signed-off-by: yangao1 <[email protected]>
1 parent 091f040 commit bf3f1db

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

testing/ostest/cancel.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ static FAR void *asynch_waiter(FAR void *parameter)
321321
static void start_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter,
322322
int cancelable)
323323
{
324+
struct sched_param param;
324325
pthread_attr_t attr;
325326
int status;
326327

@@ -356,6 +357,18 @@ static void start_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter,
356357
ASSERT(false);
357358
}
358359

360+
param.sched_priority = PRIORITY;
361+
printf("start_thread: Parent thread priority=%d\n",
362+
param.sched_priority);
363+
364+
status = pthread_attr_setschedparam(&attr, &param);
365+
if (status != 0)
366+
{
367+
printf("start_thread: ERROR pthread_attr_setschedparam failed,"
368+
"status=%d\n", status);
369+
ASSERT(false);
370+
}
371+
359372
status = pthread_attr_setstacksize(&attr, STACKSIZE);
360373
if (status != 0)
361374
{

0 commit comments

Comments
 (0)