Changeset 2cd5444 in rtems
- Timestamp:
- 11/02/99 15:58:39 (23 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 32441ab7
- Parents:
- 8f0529f
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/score/src/object.c
r8f0529f r2cd5444 126 126 127 127 /* 128 * Growing the tables means allocating a new area, doing a copy and updating129 * the information table.128 * Growing the tables means allocating a new area, doing a copy and 129 * updating the information table. 130 130 * 131 * If the maximum is minimum we do not have a table to copy. First time through. 131 * If the maximum is minimum we do not have a table to copy. First 132 * time through. 132 133 * 133 134 * The allocation has : 134 135 * 135 136 * void *objects[block_count]; 136 * unsig ed32inactive_count[block_count];137 * unsigned32 inactive_count[block_count]; 137 138 * Objects_Name *name_table[block_count]; 138 139 * Objects_Control *local_table[maximum]; … … 157 158 object_blocks = (void**) 158 159 _Workspace_Allocate( 159 block_count * (sizeof(void *) + sizeof(unsigned32) + sizeof(Objects_Name *)) + 160 block_count * 161 (sizeof(void *) + sizeof(unsigned32) + sizeof(Objects_Name *)) + 160 162 ((maximum + minimum_index) * sizeof(Objects_Control *)) 161 163 ); … … 167 169 object_blocks = (void**) 168 170 _Workspace_Allocate_or_fatal_error( 169 block_count * (sizeof(void *) + sizeof(unsigned32) + sizeof(Objects_Name *)) + 171 block_count * 172 (sizeof(void *) + sizeof(unsigned32) + sizeof(Objects_Name *)) + 170 173 ((maximum + minimum_index) * sizeof(Objects_Control *)) 171 174 ); … … 177 180 */ 178 181 179 inactive_per_block = 180 (unsigned32 *) _Addresses_Add_offset( object_blocks, block_count * sizeof(void*) ); 181 name_table = 182 (Objects_Name *) _Addresses_Add_offset( inactive_per_block, 183 block_count * sizeof(unsigned32) ); 184 local_table = 185 (Objects_Control **) _Addresses_Add_offset( name_table, 186 block_count * sizeof(Objects_Name *) ); 182 inactive_per_block = (unsigned32 *) _Addresses_Add_offset( 183 object_blocks, block_count * sizeof(void*) ); 184 name_table = (Objects_Name *) _Addresses_Add_offset( 185 inactive_per_block, block_count * sizeof(unsigned32) ); 186 local_table = (Objects_Control **) _Addresses_Add_offset( 187 name_table, block_count * sizeof(Objects_Name *) ); 187 188 188 189 /* 189 * Take the block count down. Saves all the (block_count - 1) in the copies. 190 * Take the block count down. Saves all the (block_count - 1) 191 * in the copies. 190 192 */ 191 193 … … 418 420 * 419 421 * Input parameters: 420 * information - object information table 421 * the_class - object class 422 * supports_global - TRUE if this is a global object class 423 * maximum - maximum objects of this class 424 * is_string - TRUE if names for this object are strings 425 * size - size of this object's control block 426 * is_thread - TRUE if this class is threads 422 * information - object information table 423 * the_class - object class 424 * supports_global - TRUE if this is a global object class 425 * maximum - maximum objects of this class 426 * size - size of this object's control block 427 * is_string - TRUE if names for this object are strings 428 * maximum_name_length - maximum length of each object's name 429 * is_thread - TRUE if this class is threads 427 430 * 428 431 * Output parameters: NONE … … 584 587 unsigned32 block; 585 588 586 block = 587 _Objects_Get_index( the_object->id ) -_Objects_Get_index( information->minimum_id );589 block = _Objects_Get_index( the_object->id ) - 590 _Objects_Get_index( information->minimum_id ); 588 591 block /= information->allocation_size; 589 592 … … 595 598 return the_object; 596 599 } 600 601 /*PAGE 602 * 603 * _Objects_Allocate_by_index 604 * 605 * DESCRIPTION: 606 * 607 * This function allocates the object control block 608 * specified by the index from the inactive chain of 609 * free object control blocks. 610 */ 611 612 Objects_Control *_Objects_Allocate_by_index( 613 Objects_Information *information, 614 unsigned32 index, 615 unsigned32 sizeof_control 616 ) 617 { 618 Objects_Control *the_object; 619 void *p; 620 621 if ( index && information->maximum >= index ) { 622 the_object = _Objects_Get_local_object( information, index ); 623 if ( the_object ) 624 return NULL; 625 626 /* XXX 627 * This whole section of code needs to be addressed. 628 * + The 0 should be dealt with more properly so we can autoextend. 629 * + The pointer arithmetic is probably too expensive. 630 * + etc. 631 */ 632 633 p = _Addresses_Add_offset( information->object_blocks[ 0 ], 634 (information->allocation_size * information->name_length) ), 635 636 p = _Addresses_Add_offset( p, (sizeof_control * (index - 1)) ); 637 the_object = (Objects_Control *)p; 638 _Chain_Extract( &the_object->Node ); 639 640 return the_object; 641 } 642 643 /* 644 * Autoextend will have to be thought out as it applies 645 * to user assigned indices. 646 */ 647 648 return NULL; 649 } 650 651 597 652 598 653 /*PAGE … … 834 889 * 835 890 * Output parameters: 836 * returns - address of object if local837 * location 891 * returns - address of object if local 892 * location - one of the following: 838 893 * OBJECTS_ERROR - invalid object ID 839 894 * OBJECTS_REMOTE - remote object … … 864 919 *location = OBJECTS_ERROR; 865 920 #if defined(RTEMS_MULTIPROCESSING) 866 _Objects_MP_Is_remote( information, id, location, &the_object ); 921 _Objects_MP_Is_remote( 922 information, 923 _Objects_Build_id( information->the_class, _Objects_Local_node, index ), 924 location, 925 &the_object 926 ); 867 927 return the_object; 868 928 #else … … 871 931 } 872 932 933 /*PAGE 934 * 935 * _Objects_Get_by_index 936 * 937 * This routine sets the object pointer for the given 938 * object id based on the given object information structure. 939 * 940 * Input parameters: 941 * information - pointer to entry in table for this class 942 * index - object index to check for 943 * location - address of where to store the location 944 * 945 * Output parameters: 946 * returns - address of object if local 947 * location - one of the following: 948 * OBJECTS_ERROR - invalid object ID 949 * OBJECTS_REMOTE - remote object 950 * OBJECTS_LOCAL - local object 951 */ 952 953 Objects_Control *_Objects_Get_by_index( 954 Objects_Information *information, 955 unsigned32 index, 956 Objects_Locations *location 957 ) 958 { 959 Objects_Control *the_object; 960 961 if ( information->maximum >= index ) { 962 _Thread_Disable_dispatch(); 963 if ( (the_object = _Objects_Get_local_object( information, index )) != NULL ) { 964 *location = OBJECTS_LOCAL; 965 return( the_object ); 966 } 967 _Thread_Enable_dispatch(); 968 *location = OBJECTS_ERROR; 969 return( NULL ); 970 } 971 972 /* 973 * With just an index, you can't access a remote object. 974 */ 975 976 _Thread_Enable_dispatch(); 977 *location = OBJECTS_ERROR; 978 return NULL; 979 } 873 980 874 981 /*PAGE -
cpukit/score/src/object.c
r8f0529f r2cd5444 126 126 127 127 /* 128 * Growing the tables means allocating a new area, doing a copy and updating129 * the information table.128 * Growing the tables means allocating a new area, doing a copy and 129 * updating the information table. 130 130 * 131 * If the maximum is minimum we do not have a table to copy. First time through. 131 * If the maximum is minimum we do not have a table to copy. First 132 * time through. 132 133 * 133 134 * The allocation has : 134 135 * 135 136 * void *objects[block_count]; 136 * unsig ed32inactive_count[block_count];137 * unsigned32 inactive_count[block_count]; 137 138 * Objects_Name *name_table[block_count]; 138 139 * Objects_Control *local_table[maximum]; … … 157 158 object_blocks = (void**) 158 159 _Workspace_Allocate( 159 block_count * (sizeof(void *) + sizeof(unsigned32) + sizeof(Objects_Name *)) + 160 block_count * 161 (sizeof(void *) + sizeof(unsigned32) + sizeof(Objects_Name *)) + 160 162 ((maximum + minimum_index) * sizeof(Objects_Control *)) 161 163 ); … … 167 169 object_blocks = (void**) 168 170 _Workspace_Allocate_or_fatal_error( 169 block_count * (sizeof(void *) + sizeof(unsigned32) + sizeof(Objects_Name *)) + 171 block_count * 172 (sizeof(void *) + sizeof(unsigned32) + sizeof(Objects_Name *)) + 170 173 ((maximum + minimum_index) * sizeof(Objects_Control *)) 171 174 ); … … 177 180 */ 178 181 179 inactive_per_block = 180 (unsigned32 *) _Addresses_Add_offset( object_blocks, block_count * sizeof(void*) ); 181 name_table = 182 (Objects_Name *) _Addresses_Add_offset( inactive_per_block, 183 block_count * sizeof(unsigned32) ); 184 local_table = 185 (Objects_Control **) _Addresses_Add_offset( name_table, 186 block_count * sizeof(Objects_Name *) ); 182 inactive_per_block = (unsigned32 *) _Addresses_Add_offset( 183 object_blocks, block_count * sizeof(void*) ); 184 name_table = (Objects_Name *) _Addresses_Add_offset( 185 inactive_per_block, block_count * sizeof(unsigned32) ); 186 local_table = (Objects_Control **) _Addresses_Add_offset( 187 name_table, block_count * sizeof(Objects_Name *) ); 187 188 188 189 /* 189 * Take the block count down. Saves all the (block_count - 1) in the copies. 190 * Take the block count down. Saves all the (block_count - 1) 191 * in the copies. 190 192 */ 191 193 … … 418 420 * 419 421 * Input parameters: 420 * information - object information table 421 * the_class - object class 422 * supports_global - TRUE if this is a global object class 423 * maximum - maximum objects of this class 424 * is_string - TRUE if names for this object are strings 425 * size - size of this object's control block 426 * is_thread - TRUE if this class is threads 422 * information - object information table 423 * the_class - object class 424 * supports_global - TRUE if this is a global object class 425 * maximum - maximum objects of this class 426 * size - size of this object's control block 427 * is_string - TRUE if names for this object are strings 428 * maximum_name_length - maximum length of each object's name 429 * is_thread - TRUE if this class is threads 427 430 * 428 431 * Output parameters: NONE … … 584 587 unsigned32 block; 585 588 586 block = 587 _Objects_Get_index( the_object->id ) -_Objects_Get_index( information->minimum_id );589 block = _Objects_Get_index( the_object->id ) - 590 _Objects_Get_index( information->minimum_id ); 588 591 block /= information->allocation_size; 589 592 … … 595 598 return the_object; 596 599 } 600 601 /*PAGE 602 * 603 * _Objects_Allocate_by_index 604 * 605 * DESCRIPTION: 606 * 607 * This function allocates the object control block 608 * specified by the index from the inactive chain of 609 * free object control blocks. 610 */ 611 612 Objects_Control *_Objects_Allocate_by_index( 613 Objects_Information *information, 614 unsigned32 index, 615 unsigned32 sizeof_control 616 ) 617 { 618 Objects_Control *the_object; 619 void *p; 620 621 if ( index && information->maximum >= index ) { 622 the_object = _Objects_Get_local_object( information, index ); 623 if ( the_object ) 624 return NULL; 625 626 /* XXX 627 * This whole section of code needs to be addressed. 628 * + The 0 should be dealt with more properly so we can autoextend. 629 * + The pointer arithmetic is probably too expensive. 630 * + etc. 631 */ 632 633 p = _Addresses_Add_offset( information->object_blocks[ 0 ], 634 (information->allocation_size * information->name_length) ), 635 636 p = _Addresses_Add_offset( p, (sizeof_control * (index - 1)) ); 637 the_object = (Objects_Control *)p; 638 _Chain_Extract( &the_object->Node ); 639 640 return the_object; 641 } 642 643 /* 644 * Autoextend will have to be thought out as it applies 645 * to user assigned indices. 646 */ 647 648 return NULL; 649 } 650 651 597 652 598 653 /*PAGE … … 834 889 * 835 890 * Output parameters: 836 * returns - address of object if local837 * location 891 * returns - address of object if local 892 * location - one of the following: 838 893 * OBJECTS_ERROR - invalid object ID 839 894 * OBJECTS_REMOTE - remote object … … 864 919 *location = OBJECTS_ERROR; 865 920 #if defined(RTEMS_MULTIPROCESSING) 866 _Objects_MP_Is_remote( information, id, location, &the_object ); 921 _Objects_MP_Is_remote( 922 information, 923 _Objects_Build_id( information->the_class, _Objects_Local_node, index ), 924 location, 925 &the_object 926 ); 867 927 return the_object; 868 928 #else … … 871 931 } 872 932 933 /*PAGE 934 * 935 * _Objects_Get_by_index 936 * 937 * This routine sets the object pointer for the given 938 * object id based on the given object information structure. 939 * 940 * Input parameters: 941 * information - pointer to entry in table for this class 942 * index - object index to check for 943 * location - address of where to store the location 944 * 945 * Output parameters: 946 * returns - address of object if local 947 * location - one of the following: 948 * OBJECTS_ERROR - invalid object ID 949 * OBJECTS_REMOTE - remote object 950 * OBJECTS_LOCAL - local object 951 */ 952 953 Objects_Control *_Objects_Get_by_index( 954 Objects_Information *information, 955 unsigned32 index, 956 Objects_Locations *location 957 ) 958 { 959 Objects_Control *the_object; 960 961 if ( information->maximum >= index ) { 962 _Thread_Disable_dispatch(); 963 if ( (the_object = _Objects_Get_local_object( information, index )) != NULL ) { 964 *location = OBJECTS_LOCAL; 965 return( the_object ); 966 } 967 _Thread_Enable_dispatch(); 968 *location = OBJECTS_ERROR; 969 return( NULL ); 970 } 971 972 /* 973 * With just an index, you can't access a remote object. 974 */ 975 976 _Thread_Enable_dispatch(); 977 *location = OBJECTS_ERROR; 978 return NULL; 979 } 873 980 874 981 /*PAGE
Note: See TracChangeset
for help on using the changeset viewer.