source: source/ariba/utility/transport/tcpip/protlib/testqueue.c@ 6849

Last change on this file since 6849 was 5284, checked in by mies, 15 years ago

+ added new transport modules and adapted ariba to them
+ exchange endpoint descriptors an link establishment
+ clean up of base communication
+ link establishment with in the presence of multiple endpoints
+ local discovery for ipv6, ipv4 and bluetooth mac addresses

File size: 2.6 KB
RevLine 
[5284]1/// ----------------------------------------*- mode: C++; -*--
2/// @file testqueue.c
3/// Testing fastqueue.
4/// ----------------------------------------------------------
5/// $Id: testqueue.c 2872 2008-02-18 10:58:03Z bless $
6/// $HeadURL: https://svn.ipv6.tm.uka.de/nsis/protlib/trunk/fastqueue/testqueue.c $
7// ===========================================================
8//
9// Copyright (C) 2005-2007, all rights reserved by
10// - Institute of Telematics, Universitaet Karlsruhe (TH)
11//
12// More information and contact:
13// https://projekte.tm.uka.de/trac/NSIS
14//
15// This program is free software; you can redistribute it and/or modify
16// it under the terms of the GNU General Public License as published by
17// the Free Software Foundation; version 2 of the License
18//
19// This program is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22// GNU General Public License for more details.
23//
24// You should have received a copy of the GNU General Public License along
25// with this program; if not, write to the Free Software Foundation, Inc.,
26// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27//
28// ===========================================================
29
30/**
31 * @ingroup fastqueue
32 * @{
33 */
34
35#include <stdlib.h>
36#include <stdio.h>
37#include <pthread.h> /* Headers for POSIX-Threads */
38#include <time.h> /* needed for getting Timestamps */
39
40#include "fastqueue.h"
41
42#define error_check(status,string) \
43 if (status==-1) perror(string);
44
45#define MAXELEMENTS 10000
46
47 /*** global variables ***/
48pthread_t producer_thread, /* Thread Objects (sim. to TCB) */
49 consumer_thread;
50
51float queuetime, porttime;
52
53
54/** both queues must be created before monitor tasks are started **/
55queue_t *consumer_cmdq; /** queue for consumertask **/
56struct timespec ts_start,ts_end;
57int status; /* Hold status from pthread_ calls */
58
59void *producertask(void * argp)
60{
61 long i;
62 fprintf(stderr,"QUEUETEST started. Please wait.\n");
63 clock_gettime(CLOCK_REALTIME,&ts_start);
64 for (i=1; i<=MAXELEMENTS; i++)
65 enqueue_element_signal(consumer_cmdq, (void *) i);
66
67 return NULL;
68}
69
70void *consumertask(void * argp)
71{
72 long j;
73 /** test queue **/
74 while ((j= (int) dequeue_element_wait(consumer_cmdq))<MAXELEMENTS);
75
76 clock_gettime(CLOCK_REALTIME,&ts_end);
77 queuetime= ts_end.tv_sec-ts_start.tv_sec +
78 (ts_end.tv_nsec-ts_start.tv_nsec)*1E-9;
79 fprintf(stderr,"QUEUETEST stopped (%d elements): %gs\n",MAXELEMENTS,queuetime);
80 return NULL;
81}
82
83/**** end of source ****/
84
85//@}
Note: See TracBrowser for help on using the repository browser.