Exemplo n.º 1
0
/********************************************************************************
	函数功能:催菜功能
********************************************************************************/
void Reminder_Func(void)
{
	u8 *str;
	/*老界面标志,自身界面标志,新界面标志,窗体名称,获取桌子号提示,确认提示*/
	u16 Remider_num = Get_Table_Func(&Menu_flag, &Reminder_flag,&Menu_flag,"催菜","请输入催菜桌号:","是否催菜?");
	COUSTOMER.Table = Remider_num;
	str = (u8 *)malloc(40);
	sprintf((char *)str,"%d桌客人在催菜!快点!",COUSTOMER.Table);
	Send_msg(0x08,str);
	free(str);
}
Exemplo n.º 2
0
/*-------------------------------------------------------------------*/
int main(int argc, char* argv[]) {
   int thread_count;
   int send_max;
   struct queue_s** msg_queues;
   int done_sending = 0;

   if (argc != 3) Usage(argv[0]);
   thread_count = strtol(argv[1], NULL, 10);
   send_max = strtol(argv[2], NULL, 10);
   if (thread_count <= 0 || send_max < 0) Usage(argv[0]);

   msg_queues = malloc(thread_count*sizeof(struct queue_node_s*));

#  pragma omp parallel num_threads(thread_count) \
      default(none) shared(thread_count, send_max, msg_queues, done_sending)
   {
      int my_rank = omp_get_thread_num();
      int msg_number;
      srandom(my_rank);
      msg_queues[my_rank] = Allocate_queue();

#     pragma omp barrier /* Don't let any threads send messages  */
                         /* until all queues are constructed     */

      for (msg_number = 0; msg_number < send_max; msg_number++) {
         Send_msg(msg_queues, my_rank, thread_count, msg_number);
         Try_receive(msg_queues[my_rank], my_rank);
      }
#     pragma omp atomic
      done_sending++;
#     ifdef DEBUG
      printf("Thread %d > done sending\n", my_rank);
#     endif

      while (!Done(msg_queues[my_rank], done_sending, thread_count))
         Try_receive(msg_queues[my_rank], my_rank);

      /* My queue is empty, and everyone is done sending             */
      /* So my queue won't be accessed again, and it's OK to free it */
      Free_queue(msg_queues[my_rank]);
      free(msg_queues[my_rank]);
   }  /* omp parallel */

   free(msg_queues);
   return 0;
}  /* main */