Changeset 314 for soft/giet_vm/giet_common
- Timestamp:
- Apr 21, 2014, 5:48:29 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_common/utils.c
r301 r314 374 374 375 375 /////////////////////////////////////////////////////////////////////////////////// 376 // This function is used by all drivers (_xxx_set_register() function)376 // This function is used by several drivers (_xxx_set_register() function) 377 377 // If the MMU is not activated, the virtual address is extended using 378 378 // X_IO and Y_IO to reach the cluster_io. … … 422 422 423 423 /////////////////////////////////////////////////////////////////////////////////// 424 // Takes a lock with an ll/sc atomic access. 425 // A pseudo random delay is introduced before retry in case of miss 426 // (delay average value = 100 cycles) 424 // Takes a lock with a blocking ll/sc atomic access. 425 // When the cache coherence is granted by the hardware, 426 // the first read is a standard (cacheable) lw, as the local copy 427 // can be polled when the lock is already taken by another task, reducing 428 // trafic on the interconnect. When the lock is released by the owner task, 429 // the local copy is updated or invalidated by the coherence protocol. 430 // If there is no hardware cache coherence a random delay is introduced 431 // betwween two successive retry. 427 432 /////////////////////////////////////////////////////////////////////////////////// 428 433 inline void _get_lock(unsigned int * plock) 429 434 { 435 #if NO_HARD_CC 436 430 437 register unsigned int delay = ( _get_proctime() ^ _get_procid() << 4) & 0xFF; 431 438 … … 451 458 :"r"(plock), "r"(delay) 452 459 :"$2", "$3", "$4"); 460 #else 461 462 asm volatile ( 463 "_lock_llsc: \n" 464 " lw $2, 0(%0) \n" /* dcache <= _ioc_lock current value */ 465 " bnez $2, _lock_llsc \n" /* retry if lock already taken */ 466 " nop \n" 467 " ll $2, 0(%0) \n" /* ll_buffer <= _ioc_lock current value */ 468 " bnez $2, _lock_llsc \n" /* retry if _ioc_lock already taken */ 469 " li $3, 1 \n" /* $3 <= argument for sc */ 470 " sc $3, 0(%0) \n" /* try to set _ioc_lock */ 471 " beqz $3, _lock_llsc \n" /* retry if sc failure */ 472 " nop \n" 473 : 474 :"r"(plock) 475 :"$2", "$3"); 476 #endif 477 478 // register unsigned int delay = ( _get_proctime() ^ _get_procid() << 4) & 0xFF; 479 480 // if (delay == 0) delay++; 481 482 // asm volatile ( 483 // "_lock_llsc: \n" 484 // "ll $2, 0(%0) \n" /* $2 <= _ioc_lock current value */ 485 // "bnez $2, _lock_delay \n" /* delay if _ioc_lock already taken */ 486 // "li $3, 1 \n" /* $3 <= argument for sc */ 487 // "sc $3, 0(%0) \n" /* try to set _ioc_lock */ 488 // "bnez $3, _lock_ok \n" /* exit if atomic */ 489 // "_lock_delay: \n" 490 // "move $4, %1 \n" /* $4 <= delay */ 491 // "_lock_loop: \n" 492 // "addi $4, $4, -1 \n" /* $4 <= $4 - 1 */ 493 // "bnez $4, _lock_loop \n" /* test end delay */ 494 // "nop \n" 495 // "j _lock_llsc \n" /* retry */ 496 // "nop \n"ache 497 // "_lock_ok: \n" 498 // : 499 // :"r"(plock), "r"(delay) 500 // :"$2", "$3", "$4"); 501 453 502 } 454 503
Note: See TracChangeset
for help on using the changeset viewer.