sdc-g opened a new pull request, #15985:
URL: https://github.com/apache/nuttx/pull/15985

   ## Summary
   
   To avoid level-1 interrupt break retrieve PC/A0/SP/A2 register, PS.EXCM set 
to 1 by CPU HW while handling exception/interrupt.
   
   But if context switching happens and new thread created, the thread initial 
value of PS.EXCM is used.
   
   Same behevior as ESP-IDF code:
   https://github.com/espressif/esp-idf/blob/master/
   components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c#L366
   
   ## Impact
   
   PS.EXCM initial value while new thread created.
   
   ## Testing
   
   tested by internal test case as below code
   
   ```
   static void *BusyThread(void *arg) {
     (void)arg;  // Avoid compiler warning
     while (1) {
     }
     return NULL;
   }
   
   
//-----------------------------------------------------------------------------
   static void *DebugTestThread(void *arg) {
     printf("Test Thread\n");
     return NULL;
   }
   
   
//-----------------------------------------------------------------------------
   static void *TimeSliceThread(void *arg) {
     printf("Start TimeSliceThread\n");
     while (1) {
       usleep(500 * 1000);
     }
     return NULL;
   }
   
   
//-----------------------------------------------------------------------------
   int main(int argc, char *argv[]) {
   
     // Start priority=120 thread to induce Time Slice
     pthread_t thread;
     pthread_attr_t attr;
     struct sched_param param;
   
     pthread_attr_init(&attr);
     pthread_attr_getschedparam(&attr, &param);
     param.sched_priority = 120;
     pthread_attr_setschedparam(&attr, &param);
     pthread_create(&thread, &attr, TimeSliceThread, NULL);
   
     printf("\n\n******** Test Start ********\n");
   
     pthread_t busy_thread;
     pthread_create(&busy_thread, NULL, BusyThread, NULL);
   
     pthread_t test_thread;
     while(1) {
       pthread_create(&test_thread, NULL, DebugTestThread, NULL);
       pthread_join(test_thread, NULL);
     }
   }
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to