finish exec4.12-13

This commit is contained in:
KAAAsS 2021-05-18 17:35:53 +08:00
parent 339f843bae
commit 7660d524f4
Signed by: KAAAsS
GPG Key ID: D56625F3E671882F
3 changed files with 17 additions and 2 deletions

View File

@ -13,4 +13,4 @@ define add-symbol-file-auto
end
add-symbol-file-auto ./build/kernel.img
add-symbol-file-auto ./user/build/ramdisk/yield_spin.bin
add-symbol-file-auto ./user/build/ramdisk/yield_multi_aff.bin

View File

@ -409,7 +409,15 @@ int sys_set_affinity(u64 thread_cap, s32 aff)
* Lab4
* Finish the sys_set_affinity
*/
return -1;
if (aff < -1 || aff >= PLAT_CPU_NUM) {
return -1;
}
if (thread != NULL && thread->thread_ctx != NULL) {
thread->thread_ctx->affinity = aff;
}
return 0;
}
int sys_get_affinity(u64 thread_cap)
@ -430,5 +438,8 @@ int sys_get_affinity(u64 thread_cap)
* Lab4
* Finish the sys_get_affinity
*/
if (thread != NULL && thread->thread_ctx != NULL) {
return thread->thread_ctx->affinity;
}
return -1;
}

View File

@ -72,11 +72,15 @@ int rr_sched_enqueue(struct thread *thread)
if (dest_core == NO_AFF) {
dest_core = smp_get_cpu_id();
}
if (dest_core < 0 || dest_core >= PLAT_CPU_NUM) {
return -1;
}
// 入队尾
list_append(&thread->ready_queue_node, &rr_ready_queue[dest_core]);
thread->thread_ctx->state = TS_READY;
thread->thread_ctx->cpuid = dest_core;
thread->thread_ctx->sc->budget = 0;
return 0;
}