Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbdaea86

Browse files
projectgusdpgeorge
authored andcommitted
rp2/mpthreadport: Make result of thread.get_ident() a non-zero integer.
CPython says thread identifier is a "nonzero integer", so rp2 should use a1-indexed core number rather than 0-indexed. This fixes thethread/thread_ident1 test failure on rp2 port.Unfortunately this may be a breaking change for rp2 code which makes ahard-coded comparison of thread identifier to 0 or 1.This work was funded through GitHub Sponsors.Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parentefa54c2 commitbdaea86

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎ports/rp2/mpthreadport.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ STATIC void core1_entry_wrapper(void) {
115115
}
116116

117117
mp_uint_tmp_thread_get_id(void) {
118-
// On RP2, there are only two threads, one for each core, so the thread id
119-
//is the core number.
120-
returnget_core_num();
118+
// On RP2, there are only two threads, one for each core.
119+
//_thread.get_ident() must be non-zero.
120+
returnget_core_num()+1;
121121
}
122122

123123
mp_uint_tmp_thread_create(void*(*entry)(void*),void*arg,size_t*stack_size) {
@@ -149,7 +149,7 @@ mp_uint_t mp_thread_create(void *(*entry)(void *), void *arg, size_t *stack_size
149149
// Adjust stack_size to provide room to recover from hitting the limit.
150150
*stack_size-=512;
151151

152-
return1;
152+
return2;// mp_thread_get_id() result for core 1
153153
}
154154

155155
voidmp_thread_start(void) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp