Changeset 41bfc64 in mainline
- Timestamp:
- 2024-01-20T17:24:56Z (11 months ago)
- Branches:
- master
- Children:
- 7364e2d1
- Parents:
- 3d84734
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-20 16:23:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2024-01-20 17:24:56)
- Location:
- kernel/generic
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/proc/thread.h
r3d84734 r41bfc64 135 135 136 136 /** Thread state. */ 137 state_t state;137 atomic_int_fast32_t state; 138 138 139 139 /** Thread CPU. */ -
kernel/generic/src/proc/scheduler.c
r3d84734 r41bfc64 313 313 assert(atomic_get_unordered(&THREAD->cpu) == CPU); 314 314 315 THREAD->state = Running;315 atomic_set_unordered(&THREAD->state, Running); 316 316 atomic_set_unordered(&THREAD->priority, rq_index); /* Correct rq index */ 317 317 … … 386 386 irq_spinlock_lock(&thread->lock, false); 387 387 388 assert( thread->state== Running);388 assert(atomic_get_unordered(&thread->state) == Running); 389 389 assert(atomic_get_unordered(&thread->cpu) == CPU); 390 390 … … 396 396 } 397 397 398 thread->state = Ready;398 atomic_set_unordered(&thread->state, Ready); 399 399 400 400 irq_spinlock_unlock(&thread->lock, false); … … 409 409 irq_spinlock_lock(&thread->lock, false); 410 410 411 assert( thread->state == Sleeping || thread->state== Entering);411 assert(atomic_get_unordered(&thread->state) == Sleeping || atomic_get_unordered(&thread->state) == Entering); 412 412 413 413 atomic_set_unordered(&thread->priority, 0); 414 thread->state = Ready;414 atomic_set_unordered(&thread->state, Ready); 415 415 416 416 /* Prefer the CPU on which the thread ran last */ … … 471 471 */ 472 472 panic("tid%" PRIu64 ": unexpected state %s.", 473 thread->tid, thread_states[ thread->state]);473 thread->tid, thread_states[out_state]); 474 474 break; 475 475 } … … 501 501 502 502 irq_spinlock_lock(&THREAD->lock, false); 503 THREAD->state = new_state; 503 504 atomic_set_unordered(&THREAD->state, new_state); 504 505 505 506 /* Update thread kernel accounting */ … … 809 810 thread) { 810 811 printf("%" PRIu64 "(%s) ", thread->tid, 811 thread_states[ thread->state]);812 thread_states[atomic_get_unordered(&thread->state)]); 812 813 } 813 814 printf("\n"); -
kernel/generic/src/proc/thread.c
r3d84734 r41bfc64 209 209 void thread_start(thread_t *thread) 210 210 { 211 assert( thread->state== Entering);211 assert(atomic_get_unordered(&thread->state) == Entering); 212 212 thread_requeue_sleeping(thread_ref(thread)); 213 213 } … … 269 269 270 270 thread->nomigrate = 0; 271 thread->state = Entering;271 atomic_init(&thread->state, Entering); 272 272 273 273 atomic_init(&thread->sleep_queue, NULL); … … 339 339 irq_spinlock_unlock(&thread->task->lock, false); 340 340 341 assert(( thread->state == Exiting) || (thread->state== Lingering));341 assert((atomic_get_unordered(&thread->state) == Exiting) || (atomic_get_unordered(&thread->state) == Lingering)); 342 342 343 343 /* Clear cpu->fpu_owner if set to this thread. */ … … 637 637 return EINVAL; 638 638 639 irq_spinlock_lock(&thread->lock, true); 640 state_t state = thread->state; 641 irq_spinlock_unlock(&thread->lock, true); 639 state_t state = atomic_get_unordered(&thread->state); 642 640 643 641 errno_t rc = EOK; … … 686 684 order_suffix(thread->ucycles, &ucycles, &usuffix); 687 685 order_suffix(thread->kcycles, &kcycles, &ksuffix); 686 687 state_t state = atomic_get_unordered(&thread->state); 688 688 689 689 char *name; … … 699 699 else 700 700 printf("%-8" PRIu64 " %-14s %p %-8s %p %-5" PRIu32 "\n", 701 thread->tid, name, thread, thread_states[ thread->state],701 thread->tid, name, thread, thread_states[state], 702 702 thread->task, thread->task->container); 703 703 … … 709 709 printf("none "); 710 710 711 if ( thread->state == Sleeping) {711 if (state == Sleeping) { 712 712 printf(" %p", thread->sleep_queue); 713 713 } … … 914 914 printf("Scheduling thread stack trace.\n"); 915 915 thread->btrace = true; 916 if ( thread->state== Sleeping)916 if (atomic_get_unordered(&thread->state) == Sleeping) 917 917 sleeping = true; 918 918 } else -
kernel/generic/src/sysinfo/stats.c
r3d84734 r41bfc64 303 303 stats_thread->thread_id = thread->tid; 304 304 stats_thread->task_id = thread->task->taskid; 305 stats_thread->state = thread->state;305 stats_thread->state = atomic_get_unordered(&thread->state); 306 306 stats_thread->priority = atomic_get_unordered(&thread->priority); 307 307 stats_thread->ucycles = thread->ucycles;
Note:
See TracChangeset
for help on using the changeset viewer.