stress.c

Go to the documentation of this file.
00001 /* 
00002  * stress.c 
00003  * high rate service updating while accepting a command to cause dead-lock situation
00004  *
00005  */
00006 #include <dim/dic.h>
00007 #include <dim/dis.h>
00008 #include <stdio.h>
00009 
00010 int service_id;  
00011 long infinity;
00012 
00013 void svc_cb(long *tag, int *buf, int *len)
00014 {
00015   if (buf[0] % 10000 == 0) printf("stress updated %d\n", buf[0]);
00016 }
00017   
00018 void stress_svc(long *tag, long **address, int *size)  
00019 {    
00020     *address = &infinity;  
00021     *size = sizeof(infinity);  
00022 }    
00023 
00024 void stress_cmd(long *tag, char *buf, int *size)  
00025 {  
00026   static int i = 0;
00027 
00028     if(*tag == 1) {  
00029     if (!(i % 10000)) { 
00030           printf("stress_cmd: %d %s received\n", i, buf);
00031     }
00032     i++;  
00033         dis_update_service(service_id);  
00034     }  
00035 }  
00036   
00037 int main(int argc, char **argv)  
00038 {  
00039     service_id = dis_add_service("STRESS_SVC", "L", 0, 0,  
00040         stress_svc, 0);  
00041     dis_add_cmnd("STRESS_CMD", 0, stress_cmd, 1);  
00042     dis_start_serving("STRESS_SERVER"); 
00043   dic_info_service("PYSTRESS_SVC", MONITORED, 0, 0, 0, svc_cb, 0, 0, 0); 
00044     for (infinity = 0;;) {
00045   dis_update_service(service_id);
00046   infinity++;
00047     }
00048 }  
00049 

Generated on 5 Feb 2014 for PyDIM by  doxygen 1.4.7