Skip to content

Commit 7c28484

Browse files
williamtcdnskartben
authored andcommitted
samples: smp: pi: use K_SEM_DEFINE() for simplicity
This change uses K_SEM_DEFINE() instead of calling k_sem_init() and having to check for its return value. It makes the smp pi sample a bit simpler to go through. Signed-off-by: William Tambe <[email protected]>
1 parent 5a4f0dc commit 7c28484

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

samples/arch/smp/pi/src/main.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static struct k_thread tthread[THREADS_NUM];
3030
static char th_buffer[THREADS_NUM][DIGITS_NUM + 1];
3131
static atomic_t th_counter = THREADS_NUM;
3232

33-
struct k_sem main_sem;
33+
K_SEM_DEFINE(main_sem, 0, 1);
3434

3535
void test_thread(void *arg1, void *arg2, void *arg3)
3636
{
@@ -86,11 +86,6 @@ int main(void)
8686
uint32_t start_time, stop_time, cycles_spent, nanoseconds_spent;
8787
int i;
8888

89-
if (k_sem_init(&main_sem, 0, 1)) {
90-
printk("Failed initialization!\n");
91-
return -1;
92-
}
93-
9489
printk("Calculate first %d digits of Pi independently by %d threads.\n",
9590
DIGITS_NUM, THREADS_NUM);
9691

0 commit comments

Comments
 (0)