1.15 freertos 计数器生产和消费模型

发布时间:2024年01月15日
osSemaphoreId_t myCountingSem01Handle;
const osSemaphoreAttr_t myCountingSem01_attributes = {
  .name = "myCountingSem01"
};

myCountingSem01Handle = osSemaphoreNew(5, 0, &myCountingSem01_attributes);

void StartTask02(void *argument)
{
  /* USER CODE BEGIN StartTask02 */
  /* Infinite loop */
//	stu_t s1;
  for(;;)
  {	  
	  printf("我生产了俩辆小汽车\r\n");
	  osSemaphoreRelease(myCountingSem01Handle);
	  osSemaphoreRelease(myCountingSem01Handle);
	  osDelay(1000);
  }
  /* USER CODE END StartTask02 */
}

/* USER CODE BEGIN Header_StartTask03 */
/**
* @brief Function implementing the myTask03 thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartTask03 */
void StartTask03(void *argument)
{
  /* USER CODE BEGIN StartTask03 */
  /* Infinite loop */
  for(;;)
  {
	osSemaphoreAcquire(myCountingSem01Handle,osWaitForever);
	printf("我购买了一辆小汽车\r\n");

    osDelay(1);
		
  }
  /* USER CODE END StartTask03 */
}

文章来源:https://blog.csdn.net/qq_62936323/article/details/135606029
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。