Changeset 48f89683 in rtems


Ignore:
Timestamp:
05/14/02 17:45:36 (21 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
19131e97
Parents:
06549dcf
Message:

2001-05-14 Till Straumann <strauman@…>

  • src/threaddispatch.c, src/threadhandler.c: Per PR211 fix saving/restoring floating point context. The fpsave and fprestore routines are only used in a executing context which _is_ fp and hence has the FPU enabled. The current behavior required the FPU always to be on which is very dangerous if lazy context switching is used. [Joel Note: Some ports explicitly enabled the FPU in the FP save and restore routines to avoid this.]

The patch also makes sure (on powerpc only) that the FPU is disabled
for integer tasks. Note that this is crucial if deferred fp context
switching is used. Otherwise, fp context corruption may go undetected!
Also note that even tasks which merely push/pop FP registers to/from
the stack without modifying them still MUST be FP tasks - otherwise
(if lazy FP context switching is used), FP register corruption (of
other, FP, tasks may occur)!

Furthermore, (on PPC) by default, lazy FP context save/restore
is _disabled_.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • c/src/exec/score/ChangeLog

    r06549dcf r48f89683  
     12001-05-14      Till Straumann <strauman@slac.stanford.edu>
     2
     3        * src/threaddispatch.c, src/threadhandler.c: Per PR211 fix
     4        saving/restoring floating point context.  The fpsave and fprestore
     5        routines are only used in a executing context which _is_ fp and hence
     6        has the FPU enabled. The current behavior required the FPU always to
     7        be on which is very dangerous if lazy context switching is used. 
     8        [Joel Note: Some ports explicitly enabled the FPU in the FP save and
     9        restore routines to avoid this.]
     10
     11        The patch also makes sure (on powerpc only) that the FPU is disabled
     12        for integer tasks. Note that this is crucial if deferred fp context
     13        switching is used. Otherwise, fp context corruption may go undetected!
     14        Also note that even tasks which merely push/pop FP registers to/from
     15        the stack without modifying them still MUST be FP tasks - otherwise
     16        (if lazy FP context switching is used), FP register corruption (of
     17        other, FP, tasks may occur)!
     18
     19        Furthermore, (on PPC) by default, lazy FP context save/restore
     20        is _disabled_.
     21
    1222001-04-26      Joel Sherrill <joel@OARcorp.com>
    223
  • c/src/exec/score/src/threaddispatch.c

    r06549dcf r48f89683  
    9494
    9595#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
    96 #if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE )
    97     if ( (heir->fp_context != NULL) && !_Thread_Is_allocated_fp( heir ) ) {
    98       if ( _Thread_Allocated_fp != NULL )
    99         _Context_Save_fp( &_Thread_Allocated_fp->fp_context );
    100       _Context_Restore_fp( &heir->fp_context );
    101       _Thread_Allocated_fp = heir;
    102     }
    103 #else
     96#if ( CPU_USE_DEFERRED_FP_SWITCH != TRUE )
    10497    if ( executing->fp_context != NULL )
    10598      _Context_Save_fp( &executing->fp_context );
    106 
    107     if ( heir->fp_context != NULL )
    108       _Context_Restore_fp( &heir->fp_context );
    10999#endif
    110100#endif
    111101
    112102    _Context_Switch( &executing->Registers, &heir->Registers );
     103
     104#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
     105#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE )
     106    if ( (executing->fp_context != NULL) && !_Thread_Is_allocated_fp( executing ) ) {
     107      if ( _Thread_Allocated_fp != NULL )
     108        _Context_Save_fp( &_Thread_Allocated_fp->fp_context );
     109      _Context_Restore_fp( &executing->fp_context );
     110      _Thread_Allocated_fp = executing;
     111    }
     112#else
     113    if ( executing->fp_context != NULL )
     114      _Context_Restore_fp( &executing->fp_context );
     115#endif
     116#endif
    113117
    114118    executing = _Thread_Executing;
  • c/src/exec/score/src/threadhandler.c

    r06549dcf r48f89683  
    7979#endif
    8080
     81#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
     82#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE )
     83  if ( (executing->fp_context != NULL) && !_Thread_Is_allocated_fp( executing ) ) {
     84    if ( _Thread_Allocated_fp != NULL )
     85      _Context_Save_fp( &_Thread_Allocated_fp->fp_context );
     86    _Thread_Allocated_fp = executing;
     87  }
     88#endif
     89#endif
     90
     91
    8192  /*
    8293   * Take care that 'begin' extensions get to complete before
  • cpukit/score/ChangeLog

    r06549dcf r48f89683  
     12001-05-14      Till Straumann <strauman@slac.stanford.edu>
     2
     3        * src/threaddispatch.c, src/threadhandler.c: Per PR211 fix
     4        saving/restoring floating point context.  The fpsave and fprestore
     5        routines are only used in a executing context which _is_ fp and hence
     6        has the FPU enabled. The current behavior required the FPU always to
     7        be on which is very dangerous if lazy context switching is used. 
     8        [Joel Note: Some ports explicitly enabled the FPU in the FP save and
     9        restore routines to avoid this.]
     10
     11        The patch also makes sure (on powerpc only) that the FPU is disabled
     12        for integer tasks. Note that this is crucial if deferred fp context
     13        switching is used. Otherwise, fp context corruption may go undetected!
     14        Also note that even tasks which merely push/pop FP registers to/from
     15        the stack without modifying them still MUST be FP tasks - otherwise
     16        (if lazy FP context switching is used), FP register corruption (of
     17        other, FP, tasks may occur)!
     18
     19        Furthermore, (on PPC) by default, lazy FP context save/restore
     20        is _disabled_.
     21
    1222001-04-26      Joel Sherrill <joel@OARcorp.com>
    223
  • cpukit/score/src/threaddispatch.c

    r06549dcf r48f89683  
    9494
    9595#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
    96 #if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE )
    97     if ( (heir->fp_context != NULL) && !_Thread_Is_allocated_fp( heir ) ) {
    98       if ( _Thread_Allocated_fp != NULL )
    99         _Context_Save_fp( &_Thread_Allocated_fp->fp_context );
    100       _Context_Restore_fp( &heir->fp_context );
    101       _Thread_Allocated_fp = heir;
    102     }
    103 #else
     96#if ( CPU_USE_DEFERRED_FP_SWITCH != TRUE )
    10497    if ( executing->fp_context != NULL )
    10598      _Context_Save_fp( &executing->fp_context );
    106 
    107     if ( heir->fp_context != NULL )
    108       _Context_Restore_fp( &heir->fp_context );
    10999#endif
    110100#endif
    111101
    112102    _Context_Switch( &executing->Registers, &heir->Registers );
     103
     104#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
     105#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE )
     106    if ( (executing->fp_context != NULL) && !_Thread_Is_allocated_fp( executing ) ) {
     107      if ( _Thread_Allocated_fp != NULL )
     108        _Context_Save_fp( &_Thread_Allocated_fp->fp_context );
     109      _Context_Restore_fp( &executing->fp_context );
     110      _Thread_Allocated_fp = executing;
     111    }
     112#else
     113    if ( executing->fp_context != NULL )
     114      _Context_Restore_fp( &executing->fp_context );
     115#endif
     116#endif
    113117
    114118    executing = _Thread_Executing;
  • cpukit/score/src/threadhandler.c

    r06549dcf r48f89683  
    7979#endif
    8080
     81#if ( CPU_HARDWARE_FP == TRUE ) || ( CPU_SOFTWARE_FP == TRUE )
     82#if ( CPU_USE_DEFERRED_FP_SWITCH == TRUE )
     83  if ( (executing->fp_context != NULL) && !_Thread_Is_allocated_fp( executing ) ) {
     84    if ( _Thread_Allocated_fp != NULL )
     85      _Context_Save_fp( &_Thread_Allocated_fp->fp_context );
     86    _Thread_Allocated_fp = executing;
     87  }
     88#endif
     89#endif
     90
     91
    8192  /*
    8293   * Take care that 'begin' extensions get to complete before
Note: See TracChangeset for help on using the changeset viewer.