- Timestamp:
- May 1, 2019, 5:13:47 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_ioc.h
r626 r627 180 180 * This blocking function moves one or several contiguous blocks of data 181 181 * from the block device to a - possibly remote - memory buffer. 182 * It uses an extended pointer, because the target buffer is generally a remote mapper. 182 183 * It does not uses the IOC device waiting queue and server thread, and does not use 183 184 * the IOC IRQ, but call directly the relevant IOC driver, implementing a busy-waiting … … 197 198 * This blocking function moves one or several contiguous blocks of data 198 199 * from a - possibly remote - memory buffer to the block device. 200 * It uses an extended pointer, because the target buffer is generally a remote mapper. 199 201 * It does not uses the IOC device waiting queue and server thread, and does not use 200 202 * the IOC IRQ, but call directly the relevant IOC driver, implementing a busy-waiting -
trunk/kernel/fs/fatfs.c
r626 r627 491 491 // FS_INFO sector on the IOC device. It can be called by a thead running in any cluster. 492 492 // 493 // WARNING : The free_lock protecting exclusive access to these variables493 // WARNING : The lock protecting exclusive access to these variables 494 494 // must be taken by the calling function. 495 495 ////////////////////////////////////////////////////////////////////////////////////////// … … 618 618 // FS_INFO sector on the IOC device. It can be called by a thead running in any cluster. 619 619 // 620 // WARNING : The free_lock protecting exclusive access to these variables620 // WARNING : The lock protecting exclusive access to these variables 621 621 // must be taken by the calling function. 622 622 ////////////////////////////////////////////////////////////////////////////////////////// … … 853 853 uint32_t page_count_in_file; // index of page in file (index in linked list) 854 854 uint32_t next_cluster_id; // content of current FAT slot 855 xptr_t lock_xp; // extended pointer on FAT lock 855 856 856 857 assert( (searched_page_index > 0) , … … 865 866 #endif 866 867 868 // get local pointer on VFS context (same in all clusters) 869 vfs_ctx_t * vfs_ctx = &fs_context[FS_TYPE_FATFS]; 870 867 871 // get local pointer on local FATFS context 868 fatfs_ctx_t * ctx = fs_context[FS_TYPE_FATFS].extend;872 fatfs_ctx_t * loc_fatfs_ctx = vfs_ctx->extend; 869 873 870 874 // get extended pointer and cluster on FAT mapper 871 xptr_t fat_mapper_xp = ctx->fat_mapper_xp; 872 cxy_t fat_mapper_cxy = GET_CXY( fat_mapper_xp ); 875 xptr_t fat_mapper_xp = loc_fatfs_ctx->fat_mapper_xp; 876 cxy_t fat_cxy = GET_CXY( fat_mapper_xp ); 877 878 // get local pointer on FATFS context in FAT cluster 879 fatfs_ctx_t * fat_fatfs_ctx = hal_remote_lpt( XPTR( fat_cxy , &vfs_ctx->extend ) ); 880 881 // build extended pointer on FAT lock in FAT cluster 882 lock_xp = XPTR( fat_cxy , &fat_fatfs_ctx->lock ); 883 884 // take FAT lock in read mode 885 remote_rwlock_rd_acquire( lock_xp ); 873 886 874 887 // initialize loop variable (1024 slots per page) … … 887 900 { 888 901 printk("\n[ERROR] in %s : cannot get next page from FAT mapper\n", __FUNCTION__); 902 remote_rwlock_rd_release( lock_xp ); 889 903 return -1; 890 904 } … … 895 909 896 910 // get FAT slot content 897 next_cluster_id = hal_remote_l32( XPTR( fat_mapper_cxy, 898 &buffer[current_slot_index] ) ); 911 next_cluster_id = hal_remote_l32( XPTR( fat_cxy, &buffer[current_slot_index] ) ); 899 912 900 913 #if (DEBUG_FATFS_GET_CLUSTER & 1) … … 904 917 __FUNCTION__, current_page_index, current_slot_index , next_cluster_id ); 905 918 #endif 906 907 919 // update loop variables 908 920 current_page_index = next_cluster_id >> 10; … … 914 926 { 915 927 printk("\n[ERROR] in %s : searched_cluster_id not found in FAT\n", __FUNCTION__ ); 928 remote_rwlock_rd_release( lock_xp ); 916 929 return -1; 917 930 } 918 931 932 // release FAT lock 933 remote_rwlock_rd_release( lock_xp ); 934 919 935 #if DEBUG_FATFS_GET_CLUSTER 920 936 cycle = (uint32_t)hal_get_cycles(); … … 1093 1109 fatfs_ctx->fs_info_buffer = buffer; 1094 1110 1095 remote_ queuelock_init( XPTR( local_cxy , &fatfs_ctx->free_lock ) , LOCK_FATFS_FREE );1111 remote_rwlock_init( XPTR( local_cxy , &fatfs_ctx->lock ) , LOCK_FATFS_FREE ); 1096 1112 1097 1113 #if (DEBUG_FATFS_CTX_INIT & 0x1) … … 2343 2359 2344 2360 // build relevant extended pointers on free clusters info in mapper cluster 2345 lock_xp = XPTR( fat_cxy , &fat_fatfs_ctx-> free_lock );2361 lock_xp = XPTR( fat_cxy , &fat_fatfs_ctx->lock ); 2346 2362 hint_xp = XPTR( fat_cxy , &fat_fatfs_ctx->free_cluster_hint ); 2347 2363 free_xp = XPTR( fat_cxy , &fat_fatfs_ctx->free_clusters ); 2348 2364 2349 // take the lock protecting free clusters2350 remote_ queuelock_acquire( lock_xp );2365 // take the FAT lock in write mode 2366 remote_rwlock_wr_acquire( lock_xp ); 2351 2367 2352 2368 // get hint and free_clusters values from FATFS context in FAT cluster … … 2364 2380 { 2365 2381 printk("\n[ERROR] in %s : no more free FATFS clusters\n", __FUNCTION__ ); 2366 remote_ queuelock_acquire( lock_xp );2382 remote_rwlock_wr_release( lock_xp ); 2367 2383 return -1; 2368 2384 } … … 2383 2399 { 2384 2400 printk("\n[ERROR] in %s : cannot acces FAT mapper\n", __FUNCTION__ ); 2401 remote_rwlock_wr_release( lock_xp ); 2385 2402 return -1; 2386 2403 } … … 2393 2410 { 2394 2411 printk("\n[ERROR] in %s : selected cluster %x not free\n", __FUNCTION__, cluster ); 2395 remote_ queuelock_acquire( lock_xp );2412 remote_rwlock_wr_release( lock_xp ); 2396 2413 return -1; 2397 2414 } … … 2403 2420 { 2404 2421 printk("\n[ERROR] in %s : cannot update free cluster info\n", __FUNCTION__ ); 2405 remote_ queuelock_acquire( lock_xp );2422 remote_rwlock_wr_release( lock_xp ); 2406 2423 return -1; 2407 2424 } … … 2416 2433 { 2417 2434 printk("\n[ERROR] in %s : cannot update FAT on IOC device\n", __FUNCTION__ ); 2418 remote_ queuelock_acquire( lock_xp );2435 remote_rwlock_wr_release( lock_xp ); 2419 2436 return -1; 2420 2437 } 2421 2438 2422 // release free clusters busylock2423 remote_ queuelock_release( lock_xp );2439 // release FAT lock 2440 remote_rwlock_wr_release( lock_xp ); 2424 2441 2425 2442 #if DEBUG_FATFS_CLUSTER_ALLOC … … 2492 2509 fat_fatfs_ctx = hal_remote_lpt( XPTR( mapper_cxy , &vfs_ctx->extend ) ); 2493 2510 2494 // get extended pointer on free clusterslock in FAT cluster2495 lock_xp = XPTR( mapper_cxy , &fat_fatfs_ctx-> free_lock );2496 2497 // take lock protecting free clusters2498 remote_ queuelock_acquire( lock_xp );2511 // get extended pointer on FAT lock in FAT cluster 2512 lock_xp = XPTR( mapper_cxy , &fat_fatfs_ctx->lock ); 2513 2514 // take FAT lock in write mode 2515 remote_rwlock_wr_acquire( lock_xp ); 2499 2516 2500 2517 // call the recursive function to release all clusters from FAT mapper … … 2505 2522 { 2506 2523 printk("\n[ERROR] in %s : cannot update FAT mapper\n", __FUNCTION__ ); 2507 remote_ queuelock_release( lock_xp );2524 remote_rwlock_wr_release( lock_xp ); 2508 2525 return -1; 2509 2526 } 2510 2511 // release lock protecting free cluster2512 remote_queuelock_release( lock_xp );2513 2527 2514 2528 #if (DEBUG_FATFS_RELEASE_INODE & 1) … … 2521 2535 { 2522 2536 printk("\n[ERROR] in %s : cannot update FAT on device\n", __FUNCTION__ ); 2537 remote_rwlock_wr_release( lock_xp ); 2523 2538 return -1; 2524 2539 } … … 2533 2548 { 2534 2549 printk("\n[ERROR] in %s: cannot update FS_INFO on device\n", __FUNCTION__ ); 2550 remote_rwlock_wr_release( lock_xp ); 2535 2551 return -1; 2536 2552 } 2553 2554 // release FAT lock 2555 remote_rwlock_wr_release( lock_xp ); 2537 2556 2538 2557 #if DEBUG_FATFS_RELEASE_INODE -
trunk/kernel/fs/fatfs.h
r626 r627 32 32 33 33 34 /////////////////////////////////////////////////////////////////////////////////////////// 35 // The FATFS File System implements a FAT32 read/write file system. 36 // 37 // The FATFS specific extensions to the generic VFS are the following: 38 // 39 // 1) The vfs_ctx_t "extend" field is a void* pointing on the fatfs_ctx_t structure. 40 // This structure contains various general informations such as the total 41 // number of sectors in FAT region, the number of bytes per sector, the number 42 // of sectors per cluster, the lba of FAT region, the lba of data region, or the 43 // cluster index for the root directory. It contains also an extended pointer 44 // on the FAT mapper. 45 // 46 // 2) The vfs_inode_t "extend" contains, for each inode, 47 // the first FAT cluster index (after cast to intptr). 48 // 49 // 3) The vfs_dentry_t "extend" field contains, for each dentry, the entry index 50 // in the FATFS directory (32 bytes per FATFS entry). 34 /************************************************************************************** 35 * The FATFS File System implements a FAT32 read/write file system. 36 * 37 * The FATFS specific extensions to the generic VFS are the following: 38 * 1) The vfs_ctx_t "extend" field is a void* pointing on the fatfs_ctx_t structure. 39 * This structure contains various general informations such as the total 40 * number of sectors in FAT region, the number of bytes per sector, the number 41 * of sectors per cluster, the lba of FAT region, the lba of data region, or the 42 * cluster index for the root directory. It contains also an extended pointer 43 * on the FAT mapper. 44 * 2) The vfs_inode_t "extend" contains, for each inode, 45 * the first FAT cluster index (after cast to intptr). 46 * 3) The vfs_dentry_t "extend" field contains, for each dentry, the entry index 47 * in the FATFS directory (32 bytes per FATFS entry). 48 *************************************************************************************/ 49 51 50 /////////////////////////////////////////////////////////////////////////////////////////// 52 51 … … 175 174 * This fatfs context is replicated in all clusters. 176 175 * 177 * WARNING : Almost all fields are constant values, but the <free_cluster_hint>, 178 * <free_clusters> and <free_lock> are shared variables. Moreover, the <fs_info_buffer>, 179 * only allocated in cluster 0, contains a copy of the FS_INFO sector. It is used by all 176 * WARNING 1 : All access to the FAT are protected by a remote_rwlock. 177 * - it is taken in READ mode by the fatfs_get_cluster() function to scan the 178 * linked list associated to a given inode. 179 * - it is taken in WRITE mode by the fatfs_cluster_alloc() and fatfs_release_inode() 180 * functions to modify the FAT in both the FAT mapper and on IOC device. 181 * 182 * WARNING é : Almost all fields are constant values, but the <free_cluster_hint>, 183 * <free_clusters> and <lock> are shared variables. The <fs_info_buffer>, only 184 * allocated in cluster 0, contains a copy of the FS_INFO sector. It is used by all 180 185 * kernel instances to synchronously update the free clusters info on IOC device. 181 186 * For these four variables, all kernel instances must use the values in cluster 0, 182 * and take the <free_lock> stored in this cluster for exclusive access to FAT.187 * containing the FAT mapper. 183 188 ****************************************************************************************/ 184 189 … … 198 203 uint32_t free_cluster_hint; /*! cluster[hint+1] is the first free */ 199 204 uint32_t free_clusters; /*! free clusters number */ 200 remote_ queuelock_t free_lock;/*! exclusive access to FAT */205 remote_rwlock_t lock; /*! exclusive access to FAT */ 201 206 uint8_t * fs_info_buffer; /*! local pointer on FS_INFO buffer */ 202 207 } -
trunk/kernel/kern/cluster.c
r593 r627 700 700 xptr_t txt0_xp; 701 701 xptr_t txt0_lock_xp; 702 uint32_t pref_nr; // number of owned processes in cluster cxy 702 703 703 704 assert( (cluster_is_undefined( cxy ) == false), "illegal cluster index" ); … … 707 708 lock_xp = XPTR( cxy , &LOCAL_CLUSTER->pmgr.local_lock ); 708 709 710 // get number of owned processes in cluster cxy 711 pref_nr = hal_remote_l32( XPTR( cxy , &LOCAL_CLUSTER->pmgr.pref_nr ) ); 712 713 // display nothing if no user process in cluster cxy 714 if( (owned != false) && (pref_nr < 2) ) return; 715 709 716 // get pointers on TXT0 chdev 710 717 txt0_xp = chdev_dir.txt_tx[0]; … … 721 728 remote_busylock_acquire( txt0_lock_xp ); 722 729 723 // display header724 730 nolock_printk("\n***** processes in cluster %x / cycle %d\n", 725 731 cxy , (uint32_t)hal_get_cycles() ); -
trunk/kernel/libk/remote_rwlock.c
r626 r627 2 2 * remote_rwlock.c - kernel remote read/write lock implementation. 3 3 * 4 * Authors Alain Greiner (2016,2017,2018 )4 * Authors Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites -
trunk/kernel/libk/remote_rwlock.h
r563 r627 2 2 * remote_rwlock.h - kernel remote read/writelock definition. 3 3 * 4 * Authors Alain Greiner (2016,2017,2018 )4 * Authors Alain Greiner (2016,2017,2018,2019) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites -
trunk/params-hard.mk
r626 r627 3 3 ARCH = /users/alain/soc/tsar-trunk-svn-2013/platforms/tsar_generic_iob 4 4 X_SIZE = 4 5 Y_SIZE = 25 Y_SIZE = 4 6 6 NB_PROCS = 1 7 NB_TTYS = 27 NB_TTYS = 3 8 8 IOC_TYPE = IOC_BDV 9 9 TXT_TYPE = TXT_TTY -
trunk/user/sort/sort.c
r626 r627 29 29 #include <hal_macros.h> 30 30 31 #define ARRAY_LENGTH 1024// number of items31 #define ARRAY_LENGTH 4096 // number of items 32 32 #define MAX_THREADS 1024 // 16 * 16 * 4 33 33 34 34 #define USE_DQT_BARRIER 1 // use DQT barrier if non zero 35 35 #define DISPLAY_ARRAY 0 // display items values before and after 36 #define VERBOSE 0 // for debug 37 #define INTERACTIVE_MODE 0 // for debug 36 #define DEBUG_MAIN 1 // trace main function 37 #define DEBUG_SORT 0 // trace sort function 38 #define INTERACTIVE_MODE 0 // activate idbg() during instrumentation 38 39 #define CHECK_RESULT 0 // for debug 39 40 #define INSTRUMENTATION 1 // register computation times on file … … 163 164 pthread_barrier_wait( &barrier ); 164 165 165 #if VERBOSE 166 #if DEBUG_SORT 167 if( thread_uid == 0 ) 166 168 printf("\n[sort] thread[%d] exit barrier 0\n", thread_uid ); 167 169 #endif … … 170 172 unsigned int stages = __builtin_ctz( threads ) + 1; 171 173 172 #if VERBOSE 174 #if DEBUG_SORT 175 if( thread_uid == 0 ) 173 176 printf("\n[sort] thread[%d] : start\n", thread_uid ); 174 177 #endif … … 176 179 bubbleSort( array0, items, items * thread_uid ); 177 180 178 #if VERBOSE 181 #if DEBUG_SORT 182 if( thread_uid == 0 ) 179 183 printf("\n[sort] thread[%d] : stage 0 completed\n", thread_uid ); 180 184 #endif … … 183 187 pthread_barrier_wait( &barrier ); 184 188 185 #if VERBOSE 189 #if DEBUG_SORT 190 if( thread_uid == 0 ) 186 191 printf("\n[sort] thread[%d] exit barrier 0\n", thread_uid ); 187 192 #endif … … 213 218 { 214 219 215 #if VERBOSE 220 #if DEBUG_SORT 221 if( thread_uid == 0 ) 216 222 printf("\n[sort] thread[%d] : stage %d start\n", thread_uid , i ); 217 223 #endif … … 223 229 items * thread_uid ); 224 230 225 #if VERBOSE 231 #if DEBUG_SORT 232 if( thread_uid == 0 ) 226 233 printf("\n[sort] thread[%d] : stage %d completed\n", thread_uid , i ); 227 234 #endif … … 231 238 pthread_barrier_wait( &barrier ); 232 239 233 #if VERBOSE 240 #if DEBUG_SORT 241 if( thread_uid == 0 ) 234 242 printf("\n[sort] thread[%d] exit barrier %d\n", thread_uid , i ); 235 243 #endif … … 328 336 } 329 337 330 #if VERBOSE338 #if DEBUG_MAIN 331 339 printf("\n[sort] main completes barrier init\n"); 332 340 #endif … … 338 346 } 339 347 340 #if VERBOSE348 #if DEBUG_MAIN 341 349 printf("\n[sort] main completes array init\n"); 342 350 #endif … … 376 384 else 377 385 { 378 #if VERBOSE386 #if DEBUG_MAIN 379 387 printf("\n[sort] main created thread %x \n", thread_uid ); 380 388 #endif … … 388 396 get_cycle( &seq_end_cycle ); 389 397 390 #if VERBOSE398 #if DEBUG_MAIN 391 399 printf("\n[sort] main completes sequencial init at cycle %d\n", 392 400 (unsigned int)seq_end_cycle );
Note: See TracChangeset
for help on using the changeset viewer.