Пример #1
0
void * producer_proc(void *arg)
{
    time_t cur_time;
    UnlockQueue *queue = (UnlockQueue*)arg;
    while(1)
    {
        time(&cur_time);
        srand(cur_time);
        int seed = rand() % 11111;
        printf("******************************************\n");
        student_info *stu_info = get_student_info(cur_time + seed);
        printf("put a student info to queue.\n");
        queue->Put( (unsigned char *)stu_info, sizeof(student_info));
        free(stu_info);
        printf("UnlockQueue length: %u\n", queue->GetDataLen());
        printf("******************************************\n");
        sleep(1);
    }
    return (void *)queue;
}
Пример #2
0
 void * producer_proc(void *arg)
  {
       time_t cur_time;
       kfifol *queue = (kfifol*)arg;
	int count = 0;
       while(1)
       {
           time(&cur_time);
          srand(cur_time);
          int seed = rand() % 11111;
        // printf("******************************************\n");
         student_info *stu_info = get_student_info(count);
         //  printf("put a student info to queue.\n");
          queue->Put( (unsigned char *)stu_info, sizeof(student_info));
          free(stu_info);
          //printf("kfifol length: %u\n", queue->GetDataLen());
         //printf("******************************************\n");
	count++;
//	if(count ++ > 1000000)
          sleep(1);
       }
     return (void *)queue;
   }