Changeset 709 for soft/giet_vm/giet_libs
- Timestamp:
- Oct 1, 2015, 4:20:46 PM (9 years ago)
- Location:
- soft/giet_vm/giet_libs
- Files:
-
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_libs/malloc.c
r686 r709 98 98 99 99 // checking heap segment constraints 100 if ( heap_size == 0 ) // heap segment exist 101 { 102 giet_exit("ERROR in malloc() : heap not found \n"); 103 } 104 if ( heap_size != (1<<heap_index) ) // heap size power of 2 105 { 106 giet_exit("ERROR in malloc() : heap size must be power of 2\n"); 107 } 108 if ( heap_base % heap_size ) // heap segment aligned 109 { 110 giet_exit("ERROR in malloc() : heap segment must be aligned\n"); 111 } 100 giet_pthread_assert( (heap_size != 0) , 101 "error in heap_init() : heap not found"); 102 giet_pthread_assert( (heap_size == (1<<heap_index)) , 103 "error in heap_init() : heap size must be power of 2"); 104 giet_pthread_assert( (heap_base%heap_size == 0) , 105 "error in heap_init() : heap segment must be aligned\n"); 112 106 113 107 // compute size of block containin alloc[] array … … 231 225 232 226 // checking arguments 233 if (size == 0) 234 { 235 giet_exit("\nERROR in remote_malloc() : requested size = 0 \n"); 236 } 237 if ( x >= X_SIZE ) 238 { 239 giet_exit("\nERROR in remote_malloc() : x coordinate too large\n"); 240 } 241 if ( y >= Y_SIZE ) 242 { 243 giet_exit("\nERROR in remote_malloc() : y coordinate too large\n"); 244 } 245 246 // checking initialization 247 if ( heap[x][y].init != HEAP_INITIALIZED ) 248 { 249 giet_exit("\nERROR in remote_malloc() : heap not initialized\n"); 250 } 227 giet_pthread_assert( (size != 0) , 228 "error in remote_malloc() : requested size = 0 \n"); 229 giet_pthread_assert( (x < X_SIZE) , 230 "error in remote_malloc() : x coordinate too large\n"); 231 giet_pthread_assert( (y < Y_SIZE) , 232 "error in remote_malloc() : y coordinate too large\n"); 233 giet_pthread_assert( (heap[x][y].init == HEAP_INITIALIZED) , 234 "error in remote_malloc() : heap not initialized\n"); 251 235 252 236 // normalize size … … 265 249 266 250 // check block found 267 if ( base == 0)251 if (base == 0) 268 252 { 269 253 lock_release( &heap[x][y].lock ); 270 giet_ exit("\nERROR in remote_malloc() : no more space\n");254 giet_pthread_assert( 0 , "error in remote_malloc() : no more space\n" ); 271 255 } 272 256 … … 279 263 { 280 264 lock_release( &heap[x][y].lock ); 281 giet_ exit("\nERROR in remote_malloc() : block already allocated ???\n");265 giet_pthread_assert( 0 , "error in remote_malloc() : block already allocated"); 282 266 } 283 267 … … 390 374 // check ptr value 391 375 unsigned int base = (unsigned int)ptr; 392 if ( (base < heap[x][y].heap_base) || 393 (base >= (heap[x][y].heap_base + heap[x][y].heap_size)) ) 394 { 395 giet_exit("ERROR in free() : illegal pointer for released block"); 396 } 376 giet_pthread_assert( (base >= heap[x][y].heap_base) && 377 (base < (heap[x][y].heap_base + heap[x][y].heap_size)) , 378 "error in free() : illegal pointer for released block" ); 397 379 398 380 // get the lock protecting heap[x][y] … … 410 392 { 411 393 lock_release( &heap[x][y].lock ); 412 giet_ exit("\nERROR in free() : released block not allocated ???\n");394 giet_pthread_assert( 0 , "error in free() : released block not allocated"); 413 395 } 414 396 … … 416 398 if ( base % (1 << size_index) ) 417 399 { 418 giet_exit("\nERROR in free() : released block not aligned\n"); 400 lock_release( &heap[x][y].lock ); 401 giet_pthread_assert( 0 , "error in free() : released block not aligned"); 419 402 } 420 403 -
soft/giet_vm/giet_libs/malloc.h
r686 r709 68 68 #define HEAP_INITIALIZED 0xDEADBEEF 69 69 70 #define MIN_BLOCK_SIZE 0x 8070 #define MIN_BLOCK_SIZE 0x40 71 71 72 72 //////////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/giet_libs/stdio.c
r689 r709 11 11 12 12 ////////////////////////////////////////////////////////////////////////////// 13 // /////////////////// MIPS32 related system calls ///////////////////////13 // MIPS32 related system calls 14 14 ////////////////////////////////////////////////////////////////////////////// 15 15 … … 49 49 50 50 ////////////////////////////////////////////////////////////////////////////// 51 // /////////////////// Task related system calls /////////////////////////////51 // Threads related system calls 52 52 ////////////////////////////////////////////////////////////////////////////// 53 53 54 //////////////////////////////// 55 unsigned int giet_proc_task_id() 56 { 57 return (unsigned int)sys_call( SYSCALL_LOCAL_TASK_ID, 58 0, 0, 0, 0 ); 59 } 60 61 ////////////////////////////////// 62 unsigned int giet_global_task_id() 63 { 64 return (unsigned int)sys_call( SYSCALL_GLOBAL_TASK_ID, 65 0, 0, 0, 0 ); 66 } 67 68 ///////////////////////////// 69 unsigned int giet_thread_id() 70 { 71 return (unsigned int)sys_call( SYSCALL_THREAD_ID, 72 0, 0, 0, 0 ); 73 } 74 75 ////////////////////////////// 76 void giet_exit( char* string ) 77 { 78 sys_call( SYSCALL_EXIT, 54 #define THREAD_CMD_PAUSE 0 55 #define THREAD_CMD_RESUME 1 56 #define THREAD_CMD_CONTEXT 2 57 58 ////////////////////////////////////////////////////////// 59 int giet_pthread_create( pthread_t* buffer, 60 pthread_attr_t* attr, 61 void* function, 62 void* arg ) 63 { 64 return sys_call( SYSCALL_PTHREAD_CREATE, 65 (unsigned int)buffer, 66 (unsigned int)attr, 67 (unsigned int)function, 68 (unsigned int)arg ); 69 } 70 71 ////////////////////////////////////// 72 void giet_pthread_exit( void* string ) 73 { 74 sys_call( SYSCALL_PTHREAD_EXIT, 79 75 (unsigned int)string, 80 76 0, 0, 0 ); 81 77 } 82 78 83 ///////////////////////////////////////// 84 void giet_assert( unsigned int condition, 85 char* string ) 86 { 87 if ( condition == 0 ) giet_exit( string ); 88 } 89 90 ////////////////////////// 91 void giet_context_switch() 92 { 93 sys_call( SYSCALL_CTX_SWITCH, 79 //////////////////////////////////////// 80 int giet_pthread_join( pthread_t trdid, 81 void** ptr ) 82 { 83 return sys_call( SYSCALL_PTHREAD_JOIN, 84 trdid, 85 (unsigned int)ptr, 86 0, 0 ); 87 } 88 89 /////////////////////////////////////// 90 int giet_pthread_kill( pthread_t trdid, 91 int signal ) 92 { 93 return sys_call( SYSCALL_PTHREAD_KILL, 94 trdid, 95 signal, 96 0, 0 ); 97 } 98 99 ///////////////////////// 100 void giet_pthread_yield() 101 { 102 sys_call( SYSCALL_PTHREAD_YIELD, 94 103 0, 0, 0, 0 ); 95 104 } 96 105 97 //////////////////////// 98 void giet_tasks_status() 99 { 100 sys_call( SYSCALL_TASKS_STATUS, 101 0, 0, 0, 0 ); 102 } 106 ///////////////////////////////////////////////// 107 void giet_pthread_assert( unsigned int condition, 108 char* string ) 109 { 110 if ( condition == 0 ) giet_pthread_exit( string ); 111 } 112 113 ////////////////////////////////////////////// 114 int giet_pthread_pause( char* vspace_name, 115 char* thread_name ) 116 { 117 return sys_call( SYSCALL_PTHREAD_CONTROL, 118 THREAD_CMD_PAUSE, 119 (unsigned int) vspace_name, 120 (unsigned int) thread_name, 121 0 ); 122 } 123 124 /////////////////////////////////////////////// 125 int giet_pthread_resume( char* vspace_name, 126 char* thread_name ) 127 { 128 return sys_call( SYSCALL_PTHREAD_CONTROL, 129 THREAD_CMD_RESUME, 130 (unsigned int) vspace_name, 131 (unsigned int) thread_name, 132 0 ); 133 } 134 135 /////////////////////////////////////////////// 136 int giet_pthread_context( char* vspace_name, 137 char* thread_name ) 138 { 139 return sys_call( SYSCALL_PTHREAD_CONTROL, 140 THREAD_CMD_CONTEXT, 141 (unsigned int) vspace_name, 142 (unsigned int) thread_name, 143 0 ); 144 } 145 103 146 104 147 ////////////////////////////////////////////////////////////////////////////// 105 // /////////////////// Applications system calls /////////////////////////////148 // Applications related system calls 106 149 ////////////////////////////////////////////////////////////////////////////// 107 150 … … 122 165 } 123 166 167 /////////////////////////////// 168 void giet_applications_status() 169 { 170 sys_call( SYSCALL_APPS_STATUS, 171 0, 0, 0, 0 ); 172 } 173 124 174 ////////////////////////////////////////////////////////////////////////////// 125 // /////////////////// Coprocessors system calls ////////////////////////////175 // Coprocessors related system calls 126 176 ////////////////////////////////////////////////////////////////////////////// 127 177 … … 134 184 (unsigned int)coproc_info, 135 185 0, 0 ) ) 136 giet_ exit("error in giet_coproc_alloc()");186 giet_pthread_exit("error in giet_coproc_alloc()"); 137 187 } 138 188 … … 143 193 coproc_reg_index, 144 194 0, 0, 0 ) ) 145 giet_ exit("error in giet_coproc_release()");195 giet_pthread_exit("error in giet_coproc_release()"); 146 196 } 147 197 … … 154 204 (unsigned int)desc, 155 205 0, 0 ) ) 156 giet_ exit("error in giet_coproc_channel_init()");206 giet_pthread_exit("error in giet_coproc_channel_init()"); 157 207 } 158 208 … … 163 213 coproc_reg_index, 164 214 0, 0, 0 ) ) 165 giet_ exit("error in giet_coproc_run()");215 giet_pthread_exit("error in giet_coproc_run()"); 166 216 } 167 217 … … 171 221 if ( sys_call( SYSCALL_COPROC_COMPLETED, 172 222 0, 0, 0, 0 ) ) 173 giet_ exit("error in giet_coproc_completed");223 giet_pthread_exit("error in giet_coproc_completed"); 174 224 } 175 225 176 226 177 227 ////////////////////////////////////////////////////////////////////////////// 178 // /////////////////// TTY device related system calls ///////////////////////228 // TTY device related system calls 179 229 ////////////////////////////////////////////////////////////////////////////// 180 230 … … 184 234 if ( sys_call( SYSCALL_TTY_ALLOC, 185 235 shared, 186 0, 0, 0 ) ) giet_ exit("error in giet_tty_alloc()");236 0, 0, 0 ) ) giet_pthread_exit("error in giet_tty_alloc()"); 187 237 } 188 238 … … 516 566 if (ret) 517 567 { 518 giet_ exit("ERRORin giet_tty_printf()");568 giet_pthread_exit("error in giet_tty_printf()"); 519 569 } 520 570 } // end giet_tty_printf() … … 532 582 0xFFFFFFFF, // channel index from task context 533 583 0); 534 if ( ret < 0 ) giet_ exit("error in giet_tty_getc()");584 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_getc()"); 535 585 } 536 586 while (ret != 1); … … 556 606 0xFFFFFFFF, // channel index from task context 557 607 0); 558 if ( ret < 0 ) giet_ exit("error in giet_tty_gets()");608 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_gets()"); 559 609 } 560 610 while (ret != 1); … … 578 628 0XFFFFFFFF, // channel index from task context 579 629 0 ); 580 if ( ret < 0 ) giet_ exit("error in giet_tty_gets()");630 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_gets()"); 581 631 } 582 632 } … … 595 645 0XFFFFFFFF, // channel index from task context 596 646 0 ); 597 if ( ret < 0 ) giet_ exit("error in giet_tty_gets()");647 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_gets()"); 598 648 599 649 } … … 628 678 0xFFFFFFFF, // channel index from task context 629 679 0); 630 if ( ret < 0 ) giet_ exit("error in giet_tty_getw()");680 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_getw()"); 631 681 } 632 682 while (ret != 1); … … 644 694 0xFFFFFFFF, // channel index from task context 645 695 0 ); 646 if ( ret < 0 ) giet_ exit("error in giet_tty_getw()");696 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_getw()"); 647 697 } 648 698 else if (string_byte == 0x0A) // LF character … … 662 712 0xFFFFFFFF, // channel index from task context 663 713 0 ); 664 if ( ret < 0 ) giet_ exit("error in giet_tty_getw()");714 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_getw()"); 665 715 } 666 716 } … … 701 751 0xFFFFFFFF, // channel index from task context 702 752 0 ); 703 if ( ret < 0 ) giet_ exit("error in giet_tty_getw()");753 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_getw()"); 704 754 } 705 755 // echo character '0' … … 710 760 0xFFFFFFFF, // channel index from task context 711 761 0 ); 712 if ( ret < 0 ) giet_ exit("error in giet_tty_getw()");762 if ( ret < 0 ) giet_pthread_exit("error in giet_tty_getw()"); 713 763 714 764 // return 0 value … … 719 769 720 770 ////////////////////////////////////////////////////////////////////////////////// 721 // /////////////////// TIMER related system calls ////////////////////////////////771 // TIMER related system calls 722 772 ////////////////////////////////////////////////////////////////////////////////// 723 773 … … 726 776 { 727 777 if ( sys_call( SYSCALL_TIM_ALLOC, 728 0, 0, 0, 0 ) ) giet_ exit("error in giet_timer_alloc()");778 0, 0, 0, 0 ) ) giet_pthread_exit("error in giet_timer_alloc()"); 729 779 } 730 780 … … 734 784 if ( sys_call( SYSCALL_TIM_START, 735 785 period, 736 0, 0, 0 ) ) giet_ exit("error in giet_timer_start()");786 0, 0, 0 ) ) giet_pthread_exit("error in giet_timer_start()"); 737 787 } 738 788 … … 741 791 { 742 792 if ( sys_call( SYSCALL_TIM_STOP, 743 0, 0, 0, 0 ) ) giet_ exit("error in giet_timer_stop()");793 0, 0, 0, 0 ) ) giet_pthread_exit("error in giet_timer_stop()"); 744 794 } 745 795 746 796 747 797 ////////////////////////////////////////////////////////////////////////////////// 748 // ///////////// Frame buffer device related system calls ///////////////////////798 // Frame buffer related system calls 749 799 ////////////////////////////////////////////////////////////////////////////////// 750 800 … … 753 803 { 754 804 if ( sys_call( SYSCALL_FBF_CMA_ALLOC, 755 0, 0, 0, 0 ) ) giet_ exit("error in giet_fbf_cma_alloc()");805 0, 0, 0, 0 ) ) giet_pthread_exit("error in giet_fbf_cma_alloc()"); 756 806 } 757 807 … … 766 816 (unsigned int)buf1_vbase, 767 817 (unsigned int)sts0_vaddr, 768 (unsigned int)sts1_vaddr ) ) giet_ exit("error in giet_fbf_cma_init_buf()");818 (unsigned int)sts1_vaddr ) ) giet_pthread_exit("error in giet_fbf_cma_init_buf()"); 769 819 } 770 820 … … 774 824 if ( sys_call( SYSCALL_FBF_CMA_START, 775 825 length, 776 0, 0, 0 ) ) giet_ exit("error in giet_fbf_cma_start()");826 0, 0, 0 ) ) giet_pthread_exit("error in giet_fbf_cma_start()"); 777 827 } 778 828 … … 782 832 if ( sys_call( SYSCALL_FBF_CMA_DISPLAY, 783 833 buffer, 784 0, 0, 0 ) ) giet_ exit("error in giet_fbf_cma_display()");834 0, 0, 0 ) ) giet_pthread_exit("error in giet_fbf_cma_display()"); 785 835 } 786 836 … … 789 839 { 790 840 if ( sys_call( SYSCALL_FBF_CMA_STOP, 791 0, 0, 0, 0 ) ) giet_ exit("error in giet_fbf_cma_stop()");841 0, 0, 0, 0 ) ) giet_pthread_exit("error in giet_fbf_cma_stop()"); 792 842 } 793 843 … … 801 851 (unsigned int)buffer, 802 852 length, 803 0 ) ) giet_ exit("error in giet_fbf_sync_write()");853 0 ) ) giet_pthread_exit("error in giet_fbf_sync_write()"); 804 854 } 805 855 … … 813 863 (unsigned int)buffer, 814 864 length, 815 0 ) ) giet_ exit("error in giet_fbf_sync_read()");865 0 ) ) giet_pthread_exit("error in giet_fbf_sync_read()"); 816 866 } 817 867 818 868 819 869 ////////////////////////////////////////////////////////////////////////////////// 820 // ///////////////////// NIC related system calls /////////////////////////////////870 // NIC related system calls 821 871 ////////////////////////////////////////////////////////////////////////////////// 822 872 823 //////////////////////////////////////////////////// 824 unsigned int giet_nic_rx_alloc( unsigned int xmax, 825 unsigned int ymax ) 826 { 827 int channel = sys_call( SYSCALL_NIC_ALLOC, 828 1, 829 xmax, 830 ymax, 831 0 ); 832 if ( channel < 0 ) giet_exit("error in giet_nic_rx_alloc()"); 833 834 return (unsigned int)channel; 835 } 836 837 //////////////////////////////////////////////////// 838 unsigned int giet_nic_tx_alloc( unsigned int xmax, 839 unsigned int ymax ) 840 { 841 int channel = sys_call( SYSCALL_NIC_ALLOC, 842 0, 843 xmax, 844 ymax, 845 0 ); 846 if ( channel < 0 ) giet_exit("error in giet_nic_tx_alloc()"); 847 848 return (unsigned int)channel; 849 } 850 851 ////////////////////////////////////////////// 852 void giet_nic_rx_start( unsigned int channel ) 873 ////////////////////////////////////////// 874 void giet_nic_rx_alloc( unsigned int xmax, 875 unsigned int ymax ) 876 { 877 if ( sys_call( SYSCALL_NIC_ALLOC, 878 1, // RX 879 xmax, 880 ymax, 881 0 ) ) giet_pthread_exit("error in giet_nic_rx_alloc()"); 882 } 883 884 ////////////////////////////////////////// 885 void giet_nic_tx_alloc( unsigned int xmax, 886 unsigned int ymax ) 887 { 888 if ( sys_call( SYSCALL_NIC_ALLOC, 889 0, // TX 890 xmax, 891 ymax, 892 0 ) ) giet_pthread_exit("error in giet_nic_tx_alloc()"); 893 } 894 895 //////////////////////// 896 void giet_nic_rx_start() 853 897 { 854 898 if ( sys_call( SYSCALL_NIC_START, 855 1, 856 channel, 857 0, 0 ) ) giet_exit("error in giet_nic_rx_start()"); 858 } 859 860 ////////////////////////////////////////////// 861 void giet_nic_tx_start( unsigned int channel ) 899 1, // RX 900 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_rx_start()"); 901 } 902 903 //////////////////////// 904 void giet_nic_tx_start() 862 905 { 863 906 if ( sys_call( SYSCALL_NIC_START, 864 0, 865 channel, 866 0, 0 ) ) giet_exit("error in giet_nic_tx_start()"); 867 } 868 869 /////////////////////////////////////////////////////////// 870 void giet_nic_rx_move( unsigned int channel, void* buffer ) 907 0, // TX 908 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_tx_start()"); 909 } 910 911 ///////////////////////////////////// 912 void giet_nic_rx_move( void* buffer ) 871 913 { 872 914 if ( sys_call( SYSCALL_NIC_MOVE, 873 1, 874 channel, 915 1, // RX 875 916 (unsigned int)buffer, 876 0 ) ) giet_exit("error in giet_nic_rx_move()");877 } 878 879 ///////////////////////////////////// //////////////////////880 void giet_nic_tx_move( unsigned int channel,void* buffer )917 0, 0 ) ) giet_pthread_exit("error in giet_nic_rx_move()"); 918 } 919 920 ///////////////////////////////////// 921 void giet_nic_tx_move( void* buffer ) 881 922 { 882 923 if ( sys_call( SYSCALL_NIC_MOVE, 883 0, 884 channel, 924 0, // TX 885 925 (unsigned int)buffer, 886 0 ) ) giet_exit("error in giet_nic_tx_move()");887 } 888 889 /////////////////////// //////////////////////890 void giet_nic_rx_stop( unsigned int channel)926 0, 0 ) ) giet_pthread_exit("error in giet_nic_tx_move()"); 927 } 928 929 /////////////////////// 930 void giet_nic_rx_stop() 891 931 { 892 932 if ( sys_call( SYSCALL_NIC_STOP, 893 1, 894 channel, 895 0, 0 ) ) giet_exit("error in giet_nic_rx_stop()"); 896 } 897 898 ///////////////////////////////////////////// 899 void giet_nic_tx_stop( unsigned int channel ) 933 1, // RX 934 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_rx_stop()"); 935 } 936 937 /////////////////////// 938 void giet_nic_tx_stop() 900 939 { 901 940 if ( sys_call( SYSCALL_NIC_STOP, 902 0, 903 channel, 904 0, 0 ) ) giet_exit("error in giet_nic_tx_stop()"); 905 } 906 907 ////////////////////////////////////////////// 908 void giet_nic_rx_stats( unsigned int channel ) 941 0, // TX 942 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_tx_stop()"); 943 } 944 945 //////////////////////// 946 void giet_nic_rx_stats() 909 947 { 910 948 if ( sys_call( SYSCALL_NIC_STATS, 911 1, 912 channel, 913 0, 0 ) ) giet_exit("error in giet_nic_rx_stats()"); 914 } 915 916 ////////////////////////////////////////////// 917 void giet_nic_tx_stats( unsigned int channel ) 949 1, // RX 950 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_rx_stats()"); 951 } 952 953 //////////////////////// 954 void giet_nic_tx_stats() 918 955 { 919 956 if ( sys_call( SYSCALL_NIC_STATS, 920 0, 921 channel, 922 0, 0 ) ) giet_exit("error in giet_nic_tx_stats()"); 923 } 924 925 ////////////////////////////////////////////// 926 void giet_nic_rx_clear( unsigned int channel ) 957 0, // TX 958 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_tx_stats()"); 959 } 960 961 //////////////////////// 962 void giet_nic_rx_clear() 927 963 { 928 964 if ( sys_call( SYSCALL_NIC_CLEAR, 929 1, 930 channel, 931 0, 0 ) ) giet_exit("error in giet_nic_rx_clear()"); 932 } 933 934 ////////////////////////////////////////////// 935 void giet_nic_tx_clear( unsigned int channel ) 965 1, // RX 966 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_rx_clear()"); 967 } 968 969 //////////////////////// 970 void giet_nic_tx_clear() 936 971 { 937 972 if ( sys_call( SYSCALL_NIC_CLEAR, 938 0, 939 channel, 940 0, 0 ) ) giet_exit("error in giet_nic_tx_clear()"); 973 0, // TX 974 0, 0, 0 ) ) giet_pthread_exit("error in giet_nic_tx_clear()"); 941 975 } 942 976 … … 944 978 945 979 /////////////////////////////////////////////////////////////////////////////////// 946 // /////////////////// FAT related system calls ////////////////////////////////////980 // FAT related system calls 947 981 /////////////////////////////////////////////////////////////////////////////////// 948 982 … … 984 1018 (unsigned int)buffer, 985 1019 count, 986 0 ); 1020 0 ); // no physical addressing required 987 1021 } 988 1022 … … 996 1030 (unsigned int)buffer, 997 1031 count, 998 0 ); 1032 0 ); // no physical addressing required 999 1033 } 1000 1034 … … 1068 1102 1069 1103 ////////////////////////////////////////////////////////////////////////////////// 1070 // /////////////////// Miscellaneous system calls /////////////////////////////////1104 // Miscellaneous system calls 1071 1105 ////////////////////////////////////////////////////////////////////////////////// 1072 1106 … … 1080 1114 (unsigned int)y_size, 1081 1115 (unsigned int)nprocs, 1082 0 ) ) giet_ exit("ERRORin giet_procs_number()");1116 0 ) ) giet_pthread_exit("error in giet_procs_number()"); 1083 1117 } 1084 1118 … … 1092 1126 (unsigned int) vobj_name, 1093 1127 (unsigned int) vbase, 1094 0 ) ) giet_ exit("ERRORin giet_vobj_get_vbase()");1128 0 ) ) giet_pthread_exit("error in giet_vobj_get_vbase()"); 1095 1129 } 1096 1130 … … 1104 1138 (unsigned int) vobj_name, 1105 1139 (unsigned int) length, 1106 0 ) ) giet_ exit("ERRORin giet_vobj_get_length()");1140 0 ) ) giet_pthread_exit("error in giet_vobj_get_length()"); 1107 1141 } 1108 1142 … … 1113 1147 unsigned int y ) 1114 1148 { 1115 if (sys_call( SYSCALL_HEAP_INFO,1116 1117 1118 1119 y ) ) giet_exit("ERROR in giet_heap_info()");1149 sys_call( SYSCALL_HEAP_INFO, 1150 (unsigned int)vaddr, 1151 (unsigned int)length, 1152 x, 1153 y ); 1120 1154 } 1121 1155 … … 1129 1163 (unsigned int)px, 1130 1164 (unsigned int)py, 1131 0 ) ) giet_ exit("ERRORin giet_get_xy()");1165 0 ) ) giet_pthread_exit("error in giet_get_xy()"); 1132 1166 } 1133 1167 -
soft/giet_vm/giet_libs/stdio.h
r689 r709 14 14 15 15 #include "giet_fat32/fat32_shared.h" 16 #include "giet_common/mips32_registers.h" 16 17 17 18 // These define must be synchronised with … … 20 21 #define SYSCALL_PROC_XYP 0x00 21 22 #define SYSCALL_PROC_TIME 0x01 22 #define SYSCALL_ TTY_WRITE0x0223 #define SYSCALL_ TTY_READ0x0324 #define SYSCALL_TTY_ALLOC0x0425 #define SYSCALL_TASKS_STATUS0x0523 #define SYSCALL_PROCS_NUMBER 0x02 24 #define SYSCALL_GET_XY 0x03 25 // 0x04 26 // 0x05 26 27 // 0x06 27 28 #define SYSCALL_HEAP_INFO 0x07 28 #define SYSCALL_ LOCAL_TASK_ID0x0829 #define SYSCALL_ GLOBAL_TASK_ID0x0929 #define SYSCALL_VOBJ_GET_VBASE 0x08 30 #define SYSCALL_VOBJ_GET_LENGTH 0x09 30 31 #define SYSCALL_FBF_CMA_ALLOC 0x0A 31 32 #define SYSCALL_FBF_CMA_INIT_BUF 0x0B … … 33 34 #define SYSCALL_FBF_CMA_DISPLAY 0x0D 34 35 #define SYSCALL_FBF_CMA_STOP 0x0E 35 #define SYSCALL_EXIT0x0F36 37 #define SYSCALL_ PROCS_NUMBER0x1036 // 0x0F 37 38 #define SYSCALL_APPS_STATUS 0x10 38 39 #define SYSCALL_FBF_SYNC_WRITE 0x11 39 40 #define SYSCALL_FBF_SYNC_READ 0x12 40 #define SYSCALL_THREAD_ID0x1341 // 0x13 41 42 #define SYSCALL_TIM_ALLOC 0x14 42 43 #define SYSCALL_TIM_START 0x15 … … 44 45 #define SYSCALL_KILL_APP 0x17 45 46 #define SYSCALL_EXEC_APP 0x18 46 #define SYSCALL_CTX_SWITCH0x1947 #define SYSCALL_ VOBJ_GET_VBASE0x1A48 #define SYSCALL_ VOBJ_GET_LENGTH0x1B49 #define SYSCALL_ GET_XY0x1C50 //0x1D51 //0x1E52 //0x1F47 // 0x19 48 #define SYSCALL_PTHREAD_CONTROL 0x1A 49 #define SYSCALL_PTHREAD_YIELD 0x1B 50 #define SYSCALL_PTHREAD_KILL 0x1C 51 #define SYSCALL_PTHREAD_CREATE 0x1D 52 #define SYSCALL_PTHREAD_JOIN 0x1E 53 #define SYSCALL_PTHREAD_EXIT 0x1F 53 54 54 55 #define SYSCALL_FAT_OPEN 0x20 … … 75 76 #define SYSCALL_NIC_STATS 0x34 76 77 #define SYSCALL_NIC_CLEAR 0x35 77 //0x3678 //0x3779 //0x3878 #define SYSCALL_TTY_WRITE 0x36 79 #define SYSCALL_TTY_READ 0x37 80 #define SYSCALL_TTY_ALLOC 0x38 80 81 // 0x39 81 82 // 0x3A … … 152 153 153 154 ////////////////////////////////////////////////////////////////////////// 154 // Task related system calls 155 ////////////////////////////////////////////////////////////////////////// 156 157 extern unsigned int giet_proc_task_id(); 158 159 extern unsigned int giet_global_task_id(); 160 161 extern unsigned int giet_thread_id(); 162 163 extern void giet_exit( char* string ); 164 165 extern void giet_assert( unsigned int condition, 166 char* string ); 167 168 extern void giet_context_switch(); 169 170 extern void giet_tasks_status(); 155 // Threads related system calls 156 ////////////////////////////////////////////////////////////////////////// 157 158 typedef unsigned int pthread_t; 159 160 typedef unsigned int pthread_attr_t; 161 162 extern int giet_pthread_create( pthread_t* trdid, 163 pthread_attr_t* attr, 164 void* function, 165 void* ptr ); 166 167 extern void giet_pthread_exit( void* string ); 168 169 extern int giet_pthread_join( pthread_t trdid, 170 void** ptr ); 171 172 extern int giet_pthread_kill( pthread_t thread_id, 173 int signal ); 174 175 extern void giet_pthread_yield(); 176 177 extern void giet_pthread_assert( unsigned int condition, 178 char* string ); 179 180 extern int giet_pthread_pause( char* vspace, 181 char* thread ); 182 183 extern int giet_pthread_resume( char* vspace, 184 char* thread ); 185 186 extern int giet_pthread_context( char* vspace, 187 char* thread ); 171 188 172 189 ////////////////////////////////////////////////////////////////////////// … … 177 194 178 195 extern int giet_exec_application( char* name ); 196 197 extern void giet_applications_status(); 179 198 180 199 ////////////////////////////////////////////////////////////////////////// … … 258 277 ////////////////////////////////////////////////////////////////////////// 259 278 260 extern unsigned intgiet_nic_rx_alloc( unsigned int xmax, unsigned int ymax );261 262 extern unsigned intgiet_nic_tx_alloc( unsigned int xmax, unsigned int ymax );263 264 extern void giet_nic_rx_start( unsigned int channel);265 266 extern void giet_nic_tx_start( unsigned int channel);267 268 extern void giet_nic_rx_move( unsigned int channel,void* buffer );269 270 extern void giet_nic_tx_move( unsigned int channel,void* buffer );271 272 extern void giet_nic_rx_stop( unsigned int channel);273 274 extern void giet_nic_tx_stop( unsigned int channel);275 276 extern void giet_nic_rx_stats( unsigned int channel);277 278 extern void giet_nic_tx_stats( unsigned int channel);279 280 extern void giet_nic_rx_clear( unsigned int channel);281 282 extern void giet_nic_tx_clear( unsigned int channel);279 extern void giet_nic_rx_alloc( unsigned int xmax, unsigned int ymax ); 280 281 extern void giet_nic_tx_alloc( unsigned int xmax, unsigned int ymax ); 282 283 extern void giet_nic_rx_start(); 284 285 extern void giet_nic_tx_start(); 286 287 extern void giet_nic_rx_move( void* buffer ); 288 289 extern void giet_nic_tx_move( void* buffer ); 290 291 extern void giet_nic_rx_stop(); 292 293 extern void giet_nic_tx_stop(); 294 295 extern void giet_nic_rx_stats(); 296 297 extern void giet_nic_tx_stats(); 298 299 extern void giet_nic_rx_clear(); 300 301 extern void giet_nic_tx_clear(); 283 302 284 303 ////////////////////////////////////////////////////////////////////////// -
soft/giet_vm/giet_libs/user_barrier.c
r693 r709 208 208 { 209 209 // check parameters 210 if ( x_size > 16 ) giet_exit("SQT BARRIER ERROR : x_size too large");211 if ( y_size > 16 ) giet_exit("SQT BARRIER ERROR : y_size too large");212 if ( ntasks > 8 ) giet_exit("SQT BARRIER ERROR : ntasks too large");210 giet_pthread_assert( (x_size <= 16) , "SQT BARRIER ERROR : x_size too large" ); 211 giet_pthread_assert( (y_size <= 16) , "SQT BARRIER ERROR : y_size too large" ); 212 giet_pthread_assert( (ntasks <= 8 ) , "SQT BARRIER ERROR : ntasks too large" ); 213 213 214 214 // compute SQT levels -
soft/giet_vm/giet_libs/user_lock.c
r693 r709 9 9 10 10 #include "user_lock.h" 11 #include "malloc.h" 11 12 #include "giet_config.h" 12 13 #include "stdio.h" 13 14 14 15 ////////////////////////////////////////////////////////////////////////////////// 15 // This function uses LL/SC to make an atomic increment.16 // atomic access functions 16 17 ////////////////////////////////////////////////////////////////////////////////// 18 19 ////////////////////////////////////////////////// 17 20 unsigned int atomic_increment( unsigned int* ptr, 18 21 unsigned int increment ) … … 37 40 38 41 /////////////////////////////////////////////////////////////////////////////////// 39 // This blocking function returns only when the lock has been taken. 40 /////////////////////////////////////////////////////////////////////////////////// 42 // simple lock access functions 43 /////////////////////////////////////////////////////////////////////////////////// 44 45 ////////////////////////////////////// 41 46 void lock_acquire( user_lock_t* lock ) 42 47 { … … 49 54 unsigned int lpid; 50 55 giet_proc_xyp( &x, &y, &lpid ); 51 giet_tty_printf("\n[USER_LOCK DEBUG] P[%d,%d,%d] get ticket = %d"56 giet_tty_printf("\n[USER_LOCK DEBUG] lock_acquire() : P[%d,%d,%d] get ticket = %d" 52 57 " for lock %x at cycle %d (current = %d / free = %d)\n", 53 58 x, y, lpid, ticket, … … 65 70 66 71 #if GIET_DEBUG_USER_LOCK 67 giet_tty_printf("\n[USER_LOCK DEBUG] P[%d,%d,%d] get lock %x"72 giet_tty_printf("\n[USER_LOCK DEBUG] lock_acquire() : P[%d,%d,%d] get lock %x" 68 73 " at cycle %d (current = %d / free = %d)\n", 69 74 x, y, lpid, (unsigned int)lock, … … 73 78 } 74 79 75 ////////////////////////////////////////////////////////////////////////////// 76 // This function releases the lock. 77 ////////////////////////////////////////////////////////////////////////////// 80 ////////////////////////////////////// 78 81 void lock_release( user_lock_t* lock ) 79 82 { … … 87 90 unsigned int lpid; 88 91 giet_proc_xyp( &x, &y, &lpid ); 89 giet_tty_printf("\n[USER_LOCK DEBUG] P[%d,%d,%d] release lock %x"92 giet_tty_printf("\n[USER_LOCK DEBUG] lock_release() : P[%d,%d,%d] release lock %x" 90 93 " at cycle %d (current = %d / free = %d)\n", 91 94 x, y, lpid, (unsigned int)lock, … … 95 98 } 96 99 97 ////////////////////////////////////////////////////////////////////////////// 98 // This function initializes the lock. 99 ////////////////////////////////////////////////////////////////////////////// 100 /////////////////////////////////// 100 101 void lock_init( user_lock_t* lock ) 101 102 { … … 108 109 unsigned int lpid; 109 110 giet_proc_xyp( &x, &y, &lpid ); 110 giet_tty_printf("\n[USER_LOCK DEBUG] P[%d,%d,%d] init lock %x"111 giet_tty_printf("\n[USER_LOCK DEBUG] lock_init() : P[%d,%d,%d] init lock %x" 111 112 " at cycle %d (current = %d / free = %d)\n", 112 113 x, y, lpid, (unsigned int)lock, … … 114 115 #endif 115 116 117 } 118 119 /////////////////////////////////////////////////////////////////////////////////// 120 // SQT lock access functions 121 /////////////////////////////////////////////////////////////////////////////////// 122 123 ////////////////////////////////////////////////// 124 static void sqt_lock_build( sqt_lock_t* lock, // pointer on the SQT lock 125 unsigned int x, // node X coordinate 126 unsigned int y, // node Y coordinate 127 unsigned int level, // node level 128 sqt_lock_node_t* parent, // pointer on parent node 129 unsigned int xmax, // SQT X size 130 unsigned int ymax ) // SQT Y size 131 { 132 133 #if GIET_DEBUG_USER_LOCK 134 unsigned int px; 135 unsigned int py; 136 unsigned int pl; 137 giet_proc_xyp( &px, &py, &pl ); 138 #endif 139 140 // get target node pointer 141 sqt_lock_node_t* node = lock->node[x][y][level]; 142 143 if (level == 0 ) // terminal case 144 { 145 // initializes target node 146 node->current = 0; 147 node->free = 0; 148 node->level = 0; 149 node->parent = parent; 150 node->child[0] = NULL; 151 node->child[1] = NULL; 152 node->child[2] = NULL; 153 node->child[3] = NULL; 154 155 #if GIET_DEBUG_USER_LOCK 156 giet_tty_printf("\n[USER_LOCK DEBUG] sqt_lock_build() : " 157 "P[%d,%d,%d] initialises SQT node[%d,%d,%d] = %x :\n" 158 " parent = %x / child0 = %x / child1 = %x / child2 = %x / child3 = %x\n", 159 px , py , pl , x , y , level , (unsigned int)node , 160 (unsigned int)node->parent , 161 (unsigned int)node->child[0] , 162 (unsigned int)node->child[1] , 163 (unsigned int)node->child[2] , 164 (unsigned int)node->child[3] ); 165 #endif 166 167 } 168 else // non terminal case 169 { 170 unsigned int cx[4]; // x coordinate for children 171 unsigned int cy[4]; // y coordinate for children 172 unsigned int i; // child index 173 174 // the child0 coordinates are equal to the parent coordinates 175 // other childs coordinates are incremented depending on the level value 176 cx[0] = x; 177 cy[0] = y; 178 179 cx[1] = x + (1 << (level-1)); 180 cy[1] = y; 181 182 cx[2] = x; 183 cy[2] = y + (1 << (level-1)); 184 185 cx[3] = x + (1 << (level-1)); 186 cy[3] = y + (1 << (level-1)); 187 188 // initializes target node 189 for ( i = 0 ; i < 4 ; i++ ) 190 { 191 if ( (cx[i] < xmax) && (cy[i] < ymax) ) 192 node->child[i] = lock->node[cx[i]][cy[i]][level-1]; 193 else 194 node->child[i] = NULL; 195 } 196 node->current = 0; 197 node->free = 0; 198 node->level = level; 199 node->parent = parent; 200 201 #if GIET_DEBUG_USER_LOCK 202 giet_tty_printf("\n[USER_LOCK DEBUG] sqt_lock_init() : " 203 "P[%d,%d,%d] initialises SQT node[%d,%d,%d] : \n" 204 " parent = %x / childO = %x / child1 = %x / child2 = %x / child3 = %x\n", 205 px , py , pl , x , y , level , 206 (unsigned int)node->parent , 207 (unsigned int)node->child[0] , 208 (unsigned int)node->child[1] , 209 (unsigned int)node->child[2] , 210 (unsigned int)node->child[3] ); 211 #endif 212 213 // recursive calls for children nodes 214 for ( i = 0 ; i < 4 ; i++ ) 215 { 216 if ( (cx[i] < xmax) && (cy[i] < ymax) ) 217 sqt_lock_build( lock, 218 cx[i], 219 cy[i], 220 level-1, 221 node, 222 xmax, 223 ymax ); 224 } 225 } 226 } // end _sqt_lock_build() 227 228 229 230 ////////////////////////////////////// 231 void sqt_lock_init( sqt_lock_t* lock, 232 unsigned int x_size, // number of clusters in a row 233 unsigned int y_size, // number of clusters in a col 234 unsigned int nthreads ) // threads per clusters 235 { 236 // check parameters 237 if ( x_size > 16 ) giet_pthread_exit("SQT LOCK ERROR : x_size too large"); 238 if ( y_size > 16 ) giet_pthread_exit("SQT LOCK ERROR : y_size too large"); 239 if ( nthreads > 8 ) giet_pthread_exit("SQT LOCK ERROR : nthreads too large"); 240 241 // compute SQT levels 242 unsigned int levels; 243 unsigned int z = (x_size > y_size) ? x_size : y_size; 244 levels = (z < 2) ? 1 : (z < 3) ? 2 : (z < 5) ? 3 : (z < 9) ? 4 : 5; 245 246 #if GIET_DEBUG_USER_LOCK 247 unsigned int px; 248 unsigned int py; 249 unsigned int pp; 250 giet_proc_xyp(&px, &py, &pp); 251 unsigned int side = (z < 2) ? 1 : (z < 3) ? 2 : (z < 5) ? 4 : (z < 9) ? 8 : 16; 252 giet_tty_printf("\n[USER_LOCK DEBUG] sqt_lock_init() : " 253 "P[%d,%d%d] makes sqt_nodes allocation for lock %x\n" 254 " x_size = %d / y_size = %d / levels = %d / side = %d\n", 255 px, py, pp, (unsigned int) lock, x_size , y_size , levels , side ); 256 #endif 257 258 259 unsigned int x; // x coordinate for one SQT node 260 unsigned int y; // y coordinate for one SQT node 261 unsigned int l; // level for one SQT node 262 263 for ( x = 0 ; x < x_size ; x++ ) 264 { 265 for ( y = 0 ; y < y_size ; y++ ) 266 { 267 for ( l = 0 ; l < levels ; l++ ) // level 0 nodes 268 { 269 270 if ( ( (l == 0) && ((x&0x00) == 0) && ((y&0x00) == 0) ) || 271 ( (l == 1) && ((x&0x01) == 0) && ((y&0x01) == 0) ) || 272 ( (l == 2) && ((x&0x03) == 0) && ((y&0x03) == 0) ) || 273 ( (l == 3) && ((x&0x07) == 0) && ((y&0x07) == 0) ) || 274 ( (l == 4) && ((x&0x0F) == 0) && ((y&0x0F) == 0) ) ) 275 { 276 lock->node[x][y][l] = 277 (sqt_lock_node_t*)remote_malloc( sizeof(sqt_lock_node_t), 278 x, y ); 279 280 #if GIET_DEBUG_USER_LOCK 281 giet_tty_printf("\n[USER_LOCK DEBUG] squt_lock_init() : " 282 "P[%d,%d,%d] allocates SQT node[%d,%d,%d] = %x\n", 283 px , py , pp , x , y , l , (unsigned int)lock->node[x][y][l] ); 284 #endif 285 } 286 } 287 } 288 } 289 290 // recursively initialize all SQT nodes from root to bottom 291 sqt_lock_build( lock, 292 0, 293 0, 294 levels-1, 295 NULL, 296 x_size, 297 y_size ); 298 299 asm volatile ("sync" ::: "memory"); 300 301 #if GIET_DEBUG_USER_LOCK 302 giet_tty_printf("\n[USER_LOCK DEBUG] sqt_lock_init() : " 303 "P[%d,%d,%d] completes SQT nodes initialisation\n", px, py, pp); 304 #endif 305 306 } // end sqt_lock_init() 307 308 309 ////////////////////////////////////////////////// 310 static void sqt_lock_take( sqt_lock_node_t* node ) 311 { 312 // get next free ticket from local lock 313 unsigned int ticket = atomic_increment( &node->free, 1 ); 314 315 #if GIET_DEBUG_USER_LOCK 316 unsigned int x; 317 unsigned int y; 318 unsigned int l; 319 giet_proc_xyp(&x, &y, &l); 320 giet_tty_printf("\n[USER_LOCK DEBUG] sqt_lock_take() : " 321 "P[%d,%d,%d] get ticket %d for SQT lock %x" 322 " / level = %d / current = %d / free = %d\n", 323 x , y , l , ticket , (unsigned int)node , 324 node->level , node->current , node->free ); 325 #endif 326 327 // poll the local lock current index 328 while ( (*(volatile unsigned int *)( &node->current )) != ticket ) asm volatile( "nop" ); 329 330 #if GIET_DEBUG_USER_LOCK 331 giet_tty_printf("\n[DEBUG SQT_LOCK] sqt_lock_take() : " 332 "P[%d,%d,%d] get SQT lock %x" 333 " / level = %d / current = %d / free = %d\n", 334 x , y , l , (unsigned int)node , 335 node->level , node->current , node->free ); 336 #endif 337 338 // try to take the parent node lock until top is reached 339 if ( node->parent != NULL ) sqt_lock_take( node->parent ); 340 341 } // end _sqt_lock_take() 342 343 344 ////////////////////////////////////////// 345 void sqt_lock_acquire( sqt_lock_t* lock ) 346 { 347 unsigned int x; 348 unsigned int y; 349 unsigned int p; 350 351 // get cluster coordinates 352 giet_proc_xyp( &x, &y, &p ); 353 354 #if GIET_DEBUG_USER_LOCK 355 giet_tty_printf("\n[DEBUG SQT_LOCK] sqt_lock_acquire() : " 356 "P[%d,%d,%d] try to take lock = %x / lock_node = %x\n", 357 x, y, p, lock, lock->node[x][y][0] ); 358 #endif 359 360 // try to recursively take the distributed locks (from bottom to top) 361 sqt_lock_take( lock->node[x][y][0] ); 362 } 363 364 ////////////////////////////////////////////////// 365 static void sqt_lock_give( sqt_lock_node_t* node ) 366 { 367 // release the local lock 368 node->current = node->current + 1; 369 370 #if GIET_DEBUG_USER_LOCK 371 unsigned int x; 372 unsigned int y; 373 unsigned int l; 374 giet_proc_xyp(&x, &y, &l); 375 giet_tty_printf("\n[USER_LOCK DEBUG] sqt_lock_give() : " 376 "P[%d,%d,%d] release SQT lock_node %x" 377 " / level = %d / current = %d / free = %d\n", 378 x , y , l , (unsigned int)node, 379 node->level , node->current , node->free ); 380 #endif 381 382 // reset parent node until top is reached 383 if ( node->parent != NULL ) sqt_lock_give( node->parent ); 384 385 } // end _sqt_lock_give() 386 387 ////////////////////////////////////////// 388 void sqt_lock_release( sqt_lock_t* lock ) 389 { 390 asm volatile ( "sync" ); // for consistency 391 392 unsigned int x; 393 unsigned int y; 394 unsigned int p; 395 // get cluster coordinates 396 giet_proc_xyp( &x, &y, &p ); 397 398 // recursively reset the distributed locks (from bottom to top) 399 sqt_lock_give( lock->node[x][y][0] ); 116 400 } 117 401 -
soft/giet_vm/giet_libs/user_lock.h
r461 r709 8 8 /////////////////////////////////////////////////////////////////////////////////// 9 9 10 #ifndef _GIET_FILE_LOCK_H_ 11 #define _GIET_FILE_LOCK_H_ 10 #ifndef _USER_LOCK_H_ 11 #define _USER_LOCK_H_ 12 13 #include "hard_config.h" 12 14 13 15 /////////////////////////////////////////////////////////////////////////////////// 14 // lock structure16 // simple lock structure 15 17 /////////////////////////////////////////////////////////////////////////////////// 16 18 … … 23 25 24 26 /////////////////////////////////////////////////////////////////////////////////// 25 // access functions27 // simple lock access functions 26 28 /////////////////////////////////////////////////////////////////////////////////// 27 29 … … 35 37 extern void lock_init( user_lock_t * lock ); 36 38 39 /////////////////////////////////////////////////////////////////////////////////// 40 // SQT lock structures 41 /////////////////////////////////////////////////////////////////////////////////// 42 43 typedef struct sqt_lock_node_s 44 { 45 unsigned int current; // current ticket index 46 unsigned int free; // next free ticket index 47 unsigned int level; // hierarchical level (0 is bottom) 48 struct sqt_lock_node_s* parent; // parent node (NULL for root) 49 struct sqt_lock_node_s* child[4]; // children node 50 unsigned int padding[8]; // for 64 bytes alignment 51 } sqt_lock_node_t; 52 53 typedef struct sqt_lock_s 54 { 55 sqt_lock_node_t* node[X_SIZE][Y_SIZE][5]; // array of pointers on SBT nodes 56 } sqt_lock_t; 57 58 ////////////////////////////////////////////////////////////////////////////////// 59 // SQT lock access functions 60 ////////////////////////////////////////////////////////////////////////////////// 61 62 63 extern void sqt_lock_init( sqt_lock_t* lock, 64 unsigned int x_size, 65 unsigned int y_size, 66 unsigned int ntasks ); 67 68 extern void sqt_lock_acquire( sqt_lock_t* lock ); 69 70 extern void sqt_lock_release( sqt_lock_t* lock ); 71 37 72 #endif 38 73
Note: See TracChangeset
for help on using the changeset viewer.