Changeset 8faca06 in rtems
- Timestamp:
- 04/22/96 16:46:36 (27 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- f5674938
- Parents:
- 6365f81
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/score/src/thread.c
r6365f81 r8faca06 51 51 unsigned32 index; 52 52 53 /* 54 * BOTH stacks hooks must be set or both must be NULL. 55 * Do not allow mixture. 56 */ 57 58 if ( !( ( _CPU_Table.stack_allocate_hook == 0 ) 59 == ( _CPU_Table.stack_free_hook == 0 ) ) ) 60 _Internal_error_Occurred( 61 INTERNAL_ERROR_CORE, 62 TRUE, 63 INTERNAL_ERROR_BAD_STACK_HOOK 64 ); 65 53 66 _Context_Switch_necessary = FALSE; 54 67 _Thread_Executing = NULL; … … 284 297 /*PAGE 285 298 * 299 * _Thread_Stack_Allocate 300 * 301 * Allocate the requested stack space for the thread. 302 * return the actual size allocated after any adjustment 303 * or return zero if the allocation failed. 304 * Set the Start.stack field to the address of the stack 305 */ 306 307 static unsigned32 _Thread_Stack_Allocate( 308 Thread_Control *the_thread, 309 unsigned32 stack_size) 310 { 311 void *stack_addr = 0; 312 313 if ( !_Stack_Is_enough( stack_size ) ) 314 stack_size = STACK_MINIMUM_SIZE; 315 316 /* 317 * Call ONLY the CPU table stack allocate hook, _or_ the 318 * the RTEMS workspace allocate. This is so the stack free 319 * routine can call the correct deallocation routine. 320 */ 321 if ( _CPU_Table.stack_allocate_hook ) 322 { 323 stack_addr = (*_CPU_Table.stack_allocate_hook)( stack_size ); 324 } else { 325 stack_size = _Stack_Adjust_size( stack_size ); 326 stack_addr = _Workspace_Allocate( stack_size ); 327 } 328 329 if ( !stack_addr ) 330 stack_size = 0; 331 332 the_thread->Start.stack = stack_addr; 333 334 return stack_size; 335 } 336 337 /* 338 * _Thread_Stack_Free 339 * 340 * Deallocate the Thread's stack. 341 */ 342 343 static void _Thread_Stack_Free(void *stack_addr) 344 { 345 /* 346 * Call ONLY the CPU table stack free hook, or the 347 * the RTEMS workspace free. This is so the free 348 * routine properly matches the allocation of the stack. 349 */ 350 if ( _CPU_Table.stack_free_hook ) 351 (*_CPU_Table.stack_free_hook)( stack_addr ); 352 else 353 _Workspace_Free( stack_addr ); 354 } 355 356 /*PAGE 357 * 286 358 * _Thread_Initialize 287 359 * … … 321 393 322 394 if ( !stack ) { 323 stack = _Workspace_Allocate( actual_stack_size );324 325 if ( ! stack)326 return FALSE; 327 328 the_thread->Start.stack =stack;395 actual_stack_size = _Thread_Stack_Allocate( the_thread, stack_size ); 396 397 if ( !actual_stack_size ) 398 return FALSE; /* stack allocation failed */ 399 400 stack = the_thread->Start.stack; 329 401 } else 330 402 the_thread->Start.stack = NULL; … … 345 417 if ( !fp_area ) { 346 418 if ( the_thread->Start.stack ) 347 (void) _ Workspace_Free( the_thread->Start.stack );419 (void) _Thread_Stack_Free( the_thread->Start.stack ); 348 420 return FALSE; 349 421 } … … 358 430 359 431 /* 360 * Allocate the floating pointarea for this thread432 * Allocate the extensions area for this thread 361 433 */ 362 434 … … 371 443 372 444 if ( the_thread->Start.stack ) 373 (void) _ Workspace_Free( the_thread->Start.stack );445 (void) _Thread_Stack_Free( the_thread->Start.stack ); 374 446 375 447 return FALSE; … … 414 486 415 487 if ( the_thread->Start.stack ) 416 (void) _ Workspace_Free( the_thread->Start.stack );488 (void) _Thread_Stack_Free( the_thread->Start.stack ); 417 489 418 490 return FALSE; -
c/src/exec/score/src/wkspace.c
r6365f81 r8faca06 23 23 /*PAGE 24 24 * 25 * _Workspace_Handler_initialization 26 */ 27 28 void _Workspace_Handler_initialization( 29 void *starting_address, 30 unsigned32 size 31 ) 32 { 33 unsigned32 *zero_out_array; 34 unsigned32 index; 35 unsigned32 memory_available; 36 37 if ( !starting_address || !_Addresses_Is_aligned( starting_address ) ) 38 _Internal_error_Occurred( 39 INTERNAL_ERROR_CORE, 40 TRUE, 41 INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS 42 ); 43 44 if ( _CPU_Table.do_zero_of_workspace ) { 45 for( zero_out_array = (unsigned32 *) starting_address, index = 0 ; 46 index < size / 4 ; 47 index++ ) 48 zero_out_array[ index ] = 0; 49 } 50 51 memory_available = _Heap_Initialize( 52 &_Workspace_Area, 53 starting_address, 54 size, 55 CPU_HEAP_ALIGNMENT 56 ); 57 58 if ( memory_available == 0 ) 59 _Internal_error_Occurred( 60 INTERNAL_ERROR_CORE, 61 TRUE, 62 INTERNAL_ERROR_TOO_LITTLE_WORKSPACE 63 ); 64 } 65 66 /*PAGE 67 * 25 68 * _Workspace_Allocate_or_fatal_error 26 69 * -
cpukit/score/src/thread.c
r6365f81 r8faca06 51 51 unsigned32 index; 52 52 53 /* 54 * BOTH stacks hooks must be set or both must be NULL. 55 * Do not allow mixture. 56 */ 57 58 if ( !( ( _CPU_Table.stack_allocate_hook == 0 ) 59 == ( _CPU_Table.stack_free_hook == 0 ) ) ) 60 _Internal_error_Occurred( 61 INTERNAL_ERROR_CORE, 62 TRUE, 63 INTERNAL_ERROR_BAD_STACK_HOOK 64 ); 65 53 66 _Context_Switch_necessary = FALSE; 54 67 _Thread_Executing = NULL; … … 284 297 /*PAGE 285 298 * 299 * _Thread_Stack_Allocate 300 * 301 * Allocate the requested stack space for the thread. 302 * return the actual size allocated after any adjustment 303 * or return zero if the allocation failed. 304 * Set the Start.stack field to the address of the stack 305 */ 306 307 static unsigned32 _Thread_Stack_Allocate( 308 Thread_Control *the_thread, 309 unsigned32 stack_size) 310 { 311 void *stack_addr = 0; 312 313 if ( !_Stack_Is_enough( stack_size ) ) 314 stack_size = STACK_MINIMUM_SIZE; 315 316 /* 317 * Call ONLY the CPU table stack allocate hook, _or_ the 318 * the RTEMS workspace allocate. This is so the stack free 319 * routine can call the correct deallocation routine. 320 */ 321 if ( _CPU_Table.stack_allocate_hook ) 322 { 323 stack_addr = (*_CPU_Table.stack_allocate_hook)( stack_size ); 324 } else { 325 stack_size = _Stack_Adjust_size( stack_size ); 326 stack_addr = _Workspace_Allocate( stack_size ); 327 } 328 329 if ( !stack_addr ) 330 stack_size = 0; 331 332 the_thread->Start.stack = stack_addr; 333 334 return stack_size; 335 } 336 337 /* 338 * _Thread_Stack_Free 339 * 340 * Deallocate the Thread's stack. 341 */ 342 343 static void _Thread_Stack_Free(void *stack_addr) 344 { 345 /* 346 * Call ONLY the CPU table stack free hook, or the 347 * the RTEMS workspace free. This is so the free 348 * routine properly matches the allocation of the stack. 349 */ 350 if ( _CPU_Table.stack_free_hook ) 351 (*_CPU_Table.stack_free_hook)( stack_addr ); 352 else 353 _Workspace_Free( stack_addr ); 354 } 355 356 /*PAGE 357 * 286 358 * _Thread_Initialize 287 359 * … … 321 393 322 394 if ( !stack ) { 323 stack = _Workspace_Allocate( actual_stack_size );324 325 if ( ! stack)326 return FALSE; 327 328 the_thread->Start.stack =stack;395 actual_stack_size = _Thread_Stack_Allocate( the_thread, stack_size ); 396 397 if ( !actual_stack_size ) 398 return FALSE; /* stack allocation failed */ 399 400 stack = the_thread->Start.stack; 329 401 } else 330 402 the_thread->Start.stack = NULL; … … 345 417 if ( !fp_area ) { 346 418 if ( the_thread->Start.stack ) 347 (void) _ Workspace_Free( the_thread->Start.stack );419 (void) _Thread_Stack_Free( the_thread->Start.stack ); 348 420 return FALSE; 349 421 } … … 358 430 359 431 /* 360 * Allocate the floating pointarea for this thread432 * Allocate the extensions area for this thread 361 433 */ 362 434 … … 371 443 372 444 if ( the_thread->Start.stack ) 373 (void) _ Workspace_Free( the_thread->Start.stack );445 (void) _Thread_Stack_Free( the_thread->Start.stack ); 374 446 375 447 return FALSE; … … 414 486 415 487 if ( the_thread->Start.stack ) 416 (void) _ Workspace_Free( the_thread->Start.stack );488 (void) _Thread_Stack_Free( the_thread->Start.stack ); 417 489 418 490 return FALSE; -
cpukit/score/src/wkspace.c
r6365f81 r8faca06 23 23 /*PAGE 24 24 * 25 * _Workspace_Handler_initialization 26 */ 27 28 void _Workspace_Handler_initialization( 29 void *starting_address, 30 unsigned32 size 31 ) 32 { 33 unsigned32 *zero_out_array; 34 unsigned32 index; 35 unsigned32 memory_available; 36 37 if ( !starting_address || !_Addresses_Is_aligned( starting_address ) ) 38 _Internal_error_Occurred( 39 INTERNAL_ERROR_CORE, 40 TRUE, 41 INTERNAL_ERROR_INVALID_WORKSPACE_ADDRESS 42 ); 43 44 if ( _CPU_Table.do_zero_of_workspace ) { 45 for( zero_out_array = (unsigned32 *) starting_address, index = 0 ; 46 index < size / 4 ; 47 index++ ) 48 zero_out_array[ index ] = 0; 49 } 50 51 memory_available = _Heap_Initialize( 52 &_Workspace_Area, 53 starting_address, 54 size, 55 CPU_HEAP_ALIGNMENT 56 ); 57 58 if ( memory_available == 0 ) 59 _Internal_error_Occurred( 60 INTERNAL_ERROR_CORE, 61 TRUE, 62 INTERNAL_ERROR_TOO_LITTLE_WORKSPACE 63 ); 64 } 65 66 /*PAGE 67 * 25 68 * _Workspace_Allocate_or_fatal_error 26 69 *
Note: See TracChangeset
for help on using the changeset viewer.