Changeset 626 for trunk/libs
- Timestamp:
- Apr 29, 2019, 7:25:09 PM (6 years ago)
- Location:
- trunk/libs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/libalmosmkh/almosmkh.c
r623 r626 199 199 } // end get_uint32() 200 200 201 ////////////////////////////// 202 int get_string( char * string, 203 int maxlen ) 204 { 205 int c; 206 int done = 0; 207 int length = 0; 208 209 while( done == 0 ) 210 { 211 // check buffer overflow 212 if( length >= maxlen-1 ) 213 { 214 return -1; // return failure 215 } 216 217 // read one character 218 c = getchar(); 219 220 // analyse this character 221 if ( (c >= 0x20) && (c < 0x7F) ) // printable character 222 { 223 putchar( c ); // echo 224 string[length] = (char)c; // register character in string 225 length++; // update length 226 } 227 else if (c == 0x0A) // LF character marks end of string 228 { 229 done = 1; 230 } 231 else if ( (c == 0x7F) || // DEL character 232 (c == 0x08) ) // BS character 233 { 234 if ( length > 0 ) 235 { 236 length--; 237 printf("\b \b"); // BS / / BS 238 } 239 } 240 else if ( c == 0 ) // EOF character 241 { 242 return -1; // return failure 243 } 244 } 245 246 // set NUL character in string and return success 247 string[length] = 0; 248 return 0; 249 250 } // end get_string() 251 201 252 202 253 /////////////// non standard debug functions ////////////////////////// … … 298 349 } 299 350 351 /////////////////////////////////////// 352 int display_fat( unsigned int page_id, 353 unsigned int nb_entries ) 354 { 355 return hal_user_syscall( SYS_DISPLAY, 356 DISPLAY_FAT, 357 (reg_t)page_id, 358 (reg_t)nb_entries, 0 ); 359 } 360 300 361 /////////////////////////////// 301 362 int trace( unsigned int active, … … 313 374 { 314 375 char cmd; 315 unsigned int cxy;316 unsigned int lid;317 unsigned int txt;318 unsigned int pid;319 unsigned int trdid;320 unsigned int active;321 376 322 377 while( 1 ) 323 378 { 379 // display prompt 324 380 printf("\n[idbg] cmd = "); 381 382 // get a one character command 325 383 cmd = (char)getchar(); 326 384 327 if( cmd == 'h' ) 328 { 329 printf("h\n" 330 "p : display on TXT0 process descriptors in cluster[cxy]\n" 331 "s : display on TXT0 scheduler state for core[cxy,lid]\n" 332 "v : display on TXT0 VMM state for process[cxy,pid]\n" 333 "t : display on TXT0 process decriptors attached to TXT[tid]\n" 334 "b : display on TXT0 busylocks taken by thread[pid,trdid]\n" 335 "q : display on TXT0 DQDT state\n" 336 "y : activate/desactivate trace for core[cxy,lid]\n" 337 "x : force calling process to exit\n" 338 "c : resume calling process execution\n" 339 "h : list supported commands\n"); 340 } 385 // display all busylocks owned by thread(pid,trdid) 386 if( cmd == 'b' ) 387 { 388 printf("b / pid = "); 389 unsigned int pid = get_uint32(); 390 printf(" / trdid = "); 391 unsigned int trdid = get_uint32(); 392 display_busylocks( pid , trdid ); 393 } 394 // return to calling process 395 else if( cmd == 'c' ) 396 { 397 printf("c\n"); 398 break; 399 } 400 // display FAT mapper(page,entries) 401 else if( cmd == 'f' ) 402 { 403 printf("f / page = "); 404 unsigned int page = get_uint32(); 405 printf(" / entries = "); 406 unsigned int entries = get_uint32(); 407 display_fat( page , entries ); 408 } 409 // list all supported commands 410 else if( cmd == 'h' ) 411 { 412 printf("h\n" 413 "- b : display on TXT0 busylocks taken by thread[pid,trdid]\n" 414 "- c : resume calling process execution\n" 415 "- f : display on TXT0 FAT mapper[page,entries]\n" 416 "- h : list of supported commands\n" 417 "- m : display on TXT0 mapper[path,page,nbytes]\n" 418 "- p : display on TXT0 process descriptors in cluster[cxy]\n" 419 "- q : display on TXT0 DQDT state\n" 420 "- s : display on TXT0 scheduler state for core[cxy,lid]\n" 421 "- t : display on TXT0 process decriptors attached to TXT[tid]\n" 422 "- v : display on TXT0 VMM state for process[cxy,pid]\n" 423 "- x : force calling process to exit\n" 424 "- y : activate/desactivate trace for core[cxy,lid]\n" 425 ); 426 } 427 // display MAPPER(path,page,nbytes) 428 else if( cmd == 'm' ) 429 { 430 char path[128]; 431 printf("m / path = "); 432 int error = get_string( path , 128 ); 433 printf(" / page = "); 434 unsigned int page = get_uint32(); 435 printf(" / nbytes = "); 436 unsigned int nbytes = get_uint32(); 437 if( error == 0 ) display_mapper( path , page , nbytes ); 438 } 439 // display all processes in cluster(cxy) 341 440 else if( cmd == 'p' ) 342 441 { 343 442 printf("p / cxy = "); 344 cxy = get_uint32();443 unsigned int cxy = get_uint32(); 345 444 display_cluster_processes( cxy , 0 ); 346 445 } 347 else if( cmd == 's' ) 348 { 349 printf("s / cxy = "); 350 cxy = get_uint32(); 351 printf(" / lid = "); 352 lid = get_uint32(); 353 display_sched( cxy , lid ); 354 } 355 else if( cmd == 'v' ) 356 { 357 printf("v / cxy = "); 358 cxy = get_uint32(); 359 printf(" / pid = "); 360 pid = get_uint32(); 361 display_vmm( cxy , pid ); 362 } 363 else if( cmd == 't' ) 364 { 365 printf("t / txt_id = "); 366 txt = get_uint32(); 367 display_txt_processes( txt ); 368 } 446 // display DQDT 369 447 else if( cmd == 'q' ) 370 448 { … … 372 450 display_dqdt(); 373 451 } 374 else if( cmd == 'y' ) 375 { 376 printf("y / active = "); 377 active = get_uint32(); 378 printf(" / cxy = "); 379 cxy = get_uint32(); 452 // display scheduler state for core(cxy,lid) 453 else if( cmd == 's' ) 454 { 455 printf("s / cxy = "); 456 unsigned int cxy = get_uint32(); 380 457 printf(" / lid = "); 381 lid = get_uint32(); 382 trace( active , cxy , lid ); 383 } 384 else if( cmd == 'b' ) 385 { 386 printf("b / pid = "); 387 pid = get_uint32(); 388 printf(" / trdid = "); 389 trdid = get_uint32(); 390 display_busylocks( pid , trdid ); 391 } 458 unsigned int lid = get_uint32(); 459 display_sched( cxy , lid ); 460 } 461 // display all processes attached to TXT(txt_id) 462 else if( cmd == 't' ) 463 { 464 printf("t / txt_id = "); 465 unsigned int txt_id = get_uint32(); 466 display_txt_processes( txt_id ); 467 } 468 // display vmm state for process(cxy, pid) 469 else if( cmd == 'v' ) 470 { 471 printf("v / cxy = "); 472 unsigned int cxy = get_uint32(); 473 printf(" / pid = "); 474 unsigned int pid = get_uint32(); 475 display_vmm( cxy , pid ); 476 } 477 // force the calling process to exit 392 478 else if( cmd == 'x' ) 393 479 { … … 395 481 exit( 0 ); 396 482 } 397 else if( cmd == 'c' ) 398 { 399 printf("c\n"); 400 break; 401 } 402 } 483 // activate scheduler trace for core(cxy,lid) 484 else if( cmd == 'y' ) 485 { 486 printf("y / active = "); 487 unsigned int active = get_uint32(); 488 printf(" / cxy = "); 489 unsigned int cxy = get_uint32(); 490 printf(" / lid = "); 491 unsigned int lid = get_uint32(); 492 trace( active , cxy , lid ); 493 } 494 } // en while 403 495 } // end idbg() 404 496 -
trunk/libs/libalmosmkh/almosmkh.h
r625 r626 238 238 int display_barrier( unsigned int pid ); 239 239 240 /*************************************************************************************** 241 * This debug syscall displays on the kernel terminal TXT0 the content of one given 242 * page of the FAT mapper. 243 * It can be called by any thread running in any cluster. 244 *************************************************************************************** 245 * @ page_id : page index in file. 246 * @ nb_entries : number of bytes to display. 247 * @ return 0 if success / return -1 if page not found. 248 **************************************************************************************/ 249 int display_fat( unsigned int page_id, 250 unsigned int nb_entries ); 251 240 252 /***************************************************************************************** 241 253 * This debug syscall is used to activate / desactivate the context switches trace -
trunk/libs/mini-libc/unistd.c
r625 r626 66 66 } 67 67 68 ////////////////// 69 int fsync( int fd ) 70 { 71 return hal_user_syscall( SYS_FSYNC, 72 (reg_t)fd, 0, 0, 0 ); 73 } 74 68 75 ///////////////////////////// 69 76 int getcwd( char * buf, … … 75 82 } 76 83 77 //////////// 84 ////////////////// 78 85 int getpid( void ) 79 86 { … … 132 139 } 133 140 141 ///////////////// 142 void sync( void ) 143 { 144 hal_user_syscall( SYS_SYNC, 0, 0, 0, 0 ); 145 } 146 134 147 /////////////////////////////////// 135 148 int unlink( const char * pathname ) -
trunk/libs/mini-libc/unistd.h
r610 r626 35 35 36 36 /***************************************************************************************** 37 * This function sets a timer to deliver the signal SIGALRM to the calling process, 37 * This function implements the "alarm" system call. 38 * sets a timer to deliver the signal SIGALRM to the calling process, 38 39 * after the specified number of seconds. 39 40 * If an alarm has already been set with alarm() but has not been delivered, … … 48 49 49 50 /***************************************************************************************** 50 * This function change the current working directory in the reference process descriptor. 51 * This function implements the "chdir" system call. 52 * It changes the current working directory in the reference process descriptor. 51 53 ***************************************************************************************** 52 54 * @ pathname : pathname (can be relative or absolute). … … 56 58 57 59 /***************************************************************************************** 58 * This function release the memory allocated for the file descriptor identified by 59 * the <fd> argument, and remove the fd array_entry in all process descriptor copies. 60 * This function implements the "close" system call. 61 * It releases the memory allocated for the file identified by the <fd> argument, 62 * and remove the fd array_entry in all process descriptor copies. 60 63 ***************************************************************************************** 61 64 * @ fd : file descriptor index in fd_array. … … 65 68 66 69 /***************************************************************************************** 67 * This function implement the "exec" system call on the user side.70 * This function implement the "exec" system call. 68 71 * It creates, in the same cluster as the calling thread, a new process descriptor, 69 72 * and a new associated main thread descriptor, executing a new memory image defined … … 87 90 88 91 /***************************************************************************************** 89 * This function implement the "fork" system call on the user side.92 * This function implement the "fork" system call. 90 93 * The calling process descriptor (parent process), and the associated thread descriptor 91 94 * are replicated in a - likely - remote cluster, that becomes the new process owner. … … 103 106 104 107 /***************************************************************************************** 105 * This function returns the pathname of the current working directory. 108 * This function implements the "fsync" system call. 109 * It causes all the modified data and attributes of file identified by the <fd> argument 110 * to be copied from the file mapper and file descriptor to the IOC device. 111 ***************************************************************************************** 112 * @ fd : file descriptor index in fd_array. 113 * @ return 0 if success / returns -1 if failure. 114 ****************************************************************************************/ 115 int fsync( int fd ); 116 117 /***************************************************************************************** 118 * This function implements the "getcwd" system call. 119 * It returns the pathname of the current working directory. 106 120 ***************************************************************************************** 107 121 * buf : buffer addres in user space. … … 113 127 114 128 /***************************************************************************************** 115 * This function implements the "getpid" system call on the user side. 129 * This function implements the "getpid" system call. 130 * It returns the process identifier. 116 131 ***************************************************************************************** 117 132 * @ returns the process PID for the calling thread process. … … 120 135 121 136 /***************************************************************************************** 122 * This function test whether a file descriptor refers to a terminal. 137 * This function implements the "isatty" system call. 138 * It test whether a file descriptor refers to a terminal. 123 139 ***************************************************************************************** 124 140 * @ fd : file descriptor index in fd_array. … … 128 144 129 145 /***************************************************************************************** 130 * This function repositions the offset of the file descriptor identified by <fd>, 146 * This function implements the "lseek" system call. 147 * It repositions the offset of the file descriptor identified by <fd>, 131 148 * according to the operation type defined by the <whence> argument. 132 149 ***************************************************************************************** … … 141 158 142 159 /***************************************************************************************** 143 * This function stops the calling process until any signal is received. 160 * This function implements the "pause" system call. 161 * It stops the calling process until a signal is received. 144 162 ***************************************************************************************** 145 163 * @ return 0 if success / returns -1 if failure. … … 148 166 149 167 /***************************************************************************************** 150 * This function creates in the calling thread cluster an unnamed pipe, and two151 * (read and write) file descriptors to access this pipe. The calling function must pass152 * the pointer on thefd[] array.168 * This function implements the "pipe" system call. 169 * It creates in the calling thread cluster an unnamed pipe, and two (read and write) 170 * file descriptors to access this pipe. The argument is a pointer a fd[] array. 153 171 * TODO not implemented yet... 154 172 ***************************************************************************************** … … 160 178 161 179 /***************************************************************************************** 162 * This function read bytes from an open file identified by the <fd> file descriptor. 180 * This function implements the "read" system call. 181 * It reads bytes from an open file identified by the <fd> file descriptor. 163 182 * This file can be a regular file or a character oriented device. 164 183 ***************************************************************************************** … … 173 192 174 193 /***************************************************************************************** 175 * This function removes a directory file whose name is given by <pathname>. 176 * The directory must not have any entries other than `.' and `..'. 194 * This function implements the "rmdir" system call. 195 * It removes a directory file whose name is given by <pathname>. 196 * The directory must not contain any entries other than `.' and `..'. 177 197 ***************************************************************************************** 178 198 * @ pathname : pathname (can be relative or absolute). … … 182 202 183 203 /***************************************************************************************** 184 * This function removes a directory entry identified by the <pathname> from the 185 * directory, and decrement the link count of the file referenced by the link. 204 * This function implements the "sync" system call. 205 * It forces all kernel mappers (file caches) to be copied to the IOC device. 206 ****************************************************************************************/ 207 void sync( void ); 208 209 /***************************************************************************************** 210 * This function implements the "unlink" system call. 211 * It removes a directory entry identified by the <pathname> from the parent directory, 212 * and decrement the link count of the file referenced by the link. 186 213 * If the link count reduces to zero, and no process has the file open, then all resources 187 214 * associated with the file are released. If one or more process have the file open when … … 195 222 196 223 /***************************************************************************************** 197 * This function writes bytes to an open file identified by the <fd> file descriptor. 224 * This function implements the "write" system call. 225 * It writes bytes to an open file identified by the <fd> file descriptor. 198 226 * This file can be a regular file or character oriented device. 199 227 *****************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.