add comments

This commit is contained in:
tensfile 2024-07-03 00:34:00 +08:00
parent 4a6a44681f
commit f8df4c0c61
1 changed files with 5 additions and 1 deletions

View File

@ -25,10 +25,12 @@ void entry_task_1(void *arg)
if (counter >= MAX_COUNT) {
tos_task_destroy(K_NULL);
}
// take mutex lock
err = tos_mutex_pend(&counter_lock);
if (err == K_ERR_NONE) {
counter++;
printf("Task %s: Counter is %d\n", tos_task_curr_task_get() -> name, counter);
// give mutex lock
tos_mutex_post(&counter_lock);
}
if (counter > 50) {
@ -46,10 +48,12 @@ void entry_task_2(void *arg)
if (counter >= MAX_COUNT) {
tos_task_destroy(K_NULL);
}
// take mutex lock
err = tos_mutex_pend(&counter_lock);
if (err == K_ERR_NONE) {
counter++;
printf("Task %s: Counter is %d\n", tos_task_curr_task_get() -> name, counter);
// give mutex lock
tos_mutex_post(&counter_lock);
}
tos_task_delay(300);
@ -59,7 +63,7 @@ void entry_task_2(void *arg)
int main(void)
{
tos_knl_init();
// 创建临界区保护互斥锁
// create mutex
tos_mutex_create(&counter_lock);
(void)tos_task_create(&task_1, "task1", entry_task_1, NULL,
4, stack_task_1, STK_SIZE_TASK_1, 0);