Changeset c3ee5f3 for benchmark/io
- Timestamp:
- Jan 8, 2021, 5:20:16 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 35fd2c4
- Parents:
- 390fb02
- Location:
- benchmark/io/http
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/main.cfa
r390fb02 rc3ee5f3 46 46 } 47 47 48 extern void init_protocol(void); 49 extern void deinit_protocol(void); 50 48 51 //============================================================================================= 49 52 // Main … … 56 59 //=================== 57 60 // Open Files 58 printf("Filling cache from %s\n", path); 59 fill_cache( path ); 61 if (FileExperiment == options.experiment.type) { 62 printf("Filling cache from %s\n", path); 63 fill_cache( path ); 64 } 60 65 61 66 //=================== … … 79 84 ret = bind( server_fd, (struct sockaddr *)&address, sizeof(address) ); 80 85 if(ret < 0) { 81 if(errno == 98) {86 if(errno == EADDRINUSE) { 82 87 if(waited == 0) { 83 88 printf("Waiting for port\n"); … … 108 113 #endif 109 114 options.clopts.instance = &cl; 115 116 init_protocol(); 110 117 111 118 int pipe_cnt = options.clopts.nworkers * 2; … … 162 169 } 163 170 free(fds); 171 172 deinit_protocol(); 164 173 } 165 174 -
benchmark/io/http/protocol.cfa
r390fb02 rc3ee5f3 18 18 #include "options.hfa" 19 19 20 const char * volatile date = "Wed, 17 Apr 2013 12:00:00 GMT";20 const char * volatile date = 0p; 21 21 22 22 const char * http_msgs[] = { … … 78 78 for() { 79 79 int ret = cfa_read(fd, (void*)it, count, 0, -1`s, 0p, 0p); 80 // int ret = read(fd, (void*)it, count); 80 81 if(ret == 0 ) return [OK200, true, 0, 0]; 81 82 if(ret < 0 ) { 82 83 if( errno == EAGAIN || errno == EWOULDBLOCK) continue READ; 84 // if( errno == EINVAL ) return [E400, true, 0, 0]; 83 85 abort( "read error: (%d) %s\n", (int)errno, strerror(errno) ); 84 86 } … … 129 131 } 130 132 } 133 134 //============================================================================================= 135 136 #include <clock.hfa> 137 #include <time.hfa> 138 #include <thread.hfa> 139 140 struct date_buffer { 141 char buff[100]; 142 }; 143 144 thread DateFormater { 145 int idx; 146 date_buffer buffers[2]; 147 }; 148 149 void ?{}( DateFormater & this ) { 150 ((thread&)this){ *options.clopts.instance }; 151 this.idx = 0; 152 memset( this.buffers[0].buff, 0, sizeof(this.buffers[0]) ); 153 memset( this.buffers[1].buff, 0, sizeof(this.buffers[1]) ); 154 } 155 156 void main(DateFormater & this) { 157 LOOP: for() { 158 waitfor( ^?{} : this) { 159 break LOOP; 160 } 161 or else {} 162 163 Time now = getTimeNsec(); 164 // Date: Wed, 17 Apr 2013 12:00:00 GMT 165 strftime( this.buffers[this.idx].buff, 100, "%a, %d %b %Y %H:%M:%S %Z", now ); 166 printf("Changing date to %s\n", this.buffers[this.idx].buff); 167 168 char * next = this.buffers[this.idx].buff; 169 __atomic_exchange_n((char * volatile *)&date, next, __ATOMIC_SEQ_CST); 170 this.idx = (this.idx + 1) % 2; 171 172 sleep(1`s); 173 } 174 } 175 176 //============================================================================================= 177 DateFormater * the_date_formatter; 178 179 void init_protocol(void) { 180 the_date_formatter = alloc(); 181 (*the_date_formatter){}; 182 } 183 184 void deinit_protocol(void) { 185 ^(*the_date_formatter){}; 186 free( the_date_formatter ); 187 }
Note: See TracChangeset
for help on using the changeset viewer.