Skip to content

Commit

Permalink
qos.c created.
Browse files Browse the repository at this point in the history
  • Loading branch information
nezzzu committed May 17, 2020
1 parent 8a6baf3 commit 91ef3c5
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 35 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ all: $(EXE1) $(EXE2) $(EXE3) $(EXE5)
.PHONY: all

$(EXE1):
gcc c0appz.c c0cp.c -I/usr/include/mero $(CFLAGS) $(LFLAGS) -o $(EXE1)
gcc qos.c c0appz.c c0cp.c -I/usr/include/mero $(CFLAGS) $(LFLAGS) -o $(EXE1)

$(EXE2):
gcc c0appz.c c0ct.c -I/usr/include/mero $(CFLAGS) $(LFLAGS) -o $(EXE2)
gcc qos.c c0appz.c c0ct.c -I/usr/include/mero $(CFLAGS) $(LFLAGS) -o $(EXE2)

$(EXE3):
gcc c0appz.c c0rm.c -I/usr/include/mero $(CFLAGS) $(LFLAGS) -o $(EXE3)
gcc qos.c c0appz.c c0rm.c -I/usr/include/mero $(CFLAGS) $(LFLAGS) -o $(EXE3)

$(EXE5):
gcc c0appz.c c0cp_async.c -I/usr/include/mero $(CFLAGS) $(LFLAGS) -o $(EXE5)
gcc qos.c c0appz.c c0cp_async.c -I/usr/include/mero $(CFLAGS) $(LFLAGS) -o $(EXE5)

test: $(EXE1) $(EXE2) $(EXE3) $(EXE5)
$(SUDO) dd if=/dev/urandom of=$(FILE1) bs=$(DDZ) count=$(CNT)
Expand Down
5 changes: 3 additions & 2 deletions c0appz.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,15 @@ static void clovis_aio_opgrp_fini(struct clovis_aio_opgrp *grp);
static void clovis_aio_executed_cb(struct m0_clovis_op *op);
static void clovis_aio_stable_cb(struct m0_clovis_op *op);
static void clovis_aio_failed_cb(struct m0_clovis_op *op);

/*
******************************************************************************
* GLOBAL VARIABLES
******************************************************************************
*/
int perf=0; /* performance */
int qos_total_weight=0; /* total bytes read or written */
pthread_mutex_t qos_lock; /* lock qos_total_weight */
extern int qos_total_weight; /* total bytes read or written */
extern pthread_mutex_t qos_lock; /* lock qos_total_weight */

/*
******************************************************************************
Expand Down
4 changes: 4 additions & 0 deletions c0appz.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ int c0appz_putrc(void);
int c0appz_timeout(uint64_t sz);
int c0appz_timein();

void *disp_realtime_bw(void *arg);


/*
** ECMWF REQUIREMENTS
** synchronous/asynchronous get/put etc.
Expand Down Expand Up @@ -64,6 +67,7 @@ int c0appz_generate_id(int64_t *idh, int64_t *idl);




/*
* Local variables:
* c-indentation-style: "K&R"
Expand Down
30 changes: 1 addition & 29 deletions c0cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,6 @@
******************************************************************************
*/
extern int perf; /* performance */
extern int qos_total_weight; /* bytes read or written */
extern pthread_mutex_t qos_lock;

/*
* qos_print_bw(void)
*/
int qos_print_bw(void)
{
double bw=0;
bw=(double)qos_total_weight/1000000;
/* reset total weight */
pthread_mutex_lock(&qos_lock);
qos_total_weight=0;
pthread_mutex_unlock(&qos_lock);
printf("bw = %06.3f MB/s\n",bw);
return 0;
}

/* thread function */
void *disp_realtime_bw(void *arg)
{
while(1)
{
qos_print_bw();
sleep(1);
}
return 0;
}

/* main */
int main(int argc, char **argv)
Expand All @@ -72,7 +44,7 @@ int main(int argc, char **argv)
char *fname; /* input filename */
struct stat fs; /* file statistics */
int opt; /* options */
pthread_t tid; /* realtime bw thread */
pthread_t tid; /* real-time bw thread */

/* getopt */
while((opt = getopt(argc, argv, ":p"))!=-1){
Expand Down
95 changes: 95 additions & 0 deletions qos.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/* -*- C -*- */
/*
* COPYRIGHT 2014 SEAGATE LLC
*
* THIS DRAWING/DOCUMENT, ITS SPECIFICATIONS, AND THE DATA CONTAINED
* HEREIN, ARE THE EXCLUSIVE PROPERTY OF SEAGATE LLC,
* ISSUED IN STRICT CONFIDENCE AND SHALL NOT, WITHOUT
* THE PRIOR WRITTEN PERMISSION OF SEAGATE TECHNOLOGY LIMITED,
* BE REPRODUCED, COPIED, OR DISCLOSED TO A THIRD PARTY, OR
* USED FOR ANY PURPOSE WHATSOEVER, OR STORED IN A RETRIEVAL SYSTEM
* EXCEPT AS ALLOWED BY THE TERMS OF SEAGATE LICENSES AND AGREEMENTS.
*
* YOU SHOULD HAVE RECEIVED A COPY OF SEAGATE'S LICENSE ALONG WITH
* THIS RELEASE. IF NOT PLEASE CONTACT A SEAGATE REPRESENTATIVE
* http://www.xyratex.com/contact
*
* Original author: Ganesan Umanesan <[email protected]>
* Original creation date: 18-May-2020
*
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>

/*
******************************************************************************
* GLOBAL VARIABLES
******************************************************************************
*/
int qos_total_weight=0; /* total bytes read or written */
pthread_mutex_t qos_lock; /* lock qos_total_weight */

/*
******************************************************************************
* STATIC FUNCTION PROTOTYPES
******************************************************************************
*/
static int qos_print_bw(void);



/*
******************************************************************************
* EXTERN FUNCTIONS
******************************************************************************
*/

/*
* disp_realtime_bw()
* thread function that displays real-time
* bandwidth
*/
void *disp_realtime_bw(void *arg)
{
while(1)
{
qos_print_bw();
sleep(1);
}
return 0;
}

/*
******************************************************************************
* STATIC FUNCTIONS
******************************************************************************
*/

/*
* qos_print_bw()
*/
static int qos_print_bw(void)
{
double bw=0;
bw=(double)qos_total_weight/1000000;
/* reset total weight */
pthread_mutex_lock(&qos_lock);
qos_total_weight=0;
pthread_mutex_unlock(&qos_lock);
printf("bw = %06.3f MB/s\n",bw);
return 0;
}

/*
* Local variables:
* c-indentation-style: "K&R"
* c-basic-offset: 8
* tab-width: 8
* fill-column: 80
* scroll-step: 1
* End:
*/

0 comments on commit 91ef3c5

Please sign in to comment.