From 75267dd103637d38fa95ecdee0eedb16ba0f662c Mon Sep 17 00:00:00 2001 From: Almudena Garcia Date: Sun, 27 Oct 2019 23:14:15 +0100 Subject: patch: add last_processor to thread info structures * include/mach/thread_info.h (thread info structures): Add new member "last_processor" in thread_sched_info. * kern/thread.c (thread management): Fill new member "last_processor" in thread_info() function. --- kern/thread.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'kern') diff --git a/kern/thread.c b/kern/thread.c index 73d9b5a4..680e72c2 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -1580,8 +1580,11 @@ kern_return_t thread_info( else if (flavor == THREAD_SCHED_INFO) { thread_sched_info_t sched_info; - if (*thread_info_count < THREAD_SCHED_INFO_COUNT) { - return KERN_INVALID_ARGUMENT; + /* Allow *thread_info_count to be one smaller than the + usual amount, because last_processor is a + new member that some callers might not know about. */ + if (*thread_info_count < THREAD_SCHED_INFO_COUNT -1) { + return KERN_INVALID_ARGUMENT; } sched_info = (thread_sched_info_t) thread_info_out; @@ -1609,6 +1612,12 @@ kern_return_t thread_info( sched_info->depressed = (thread->depress_priority >= 0); sched_info->depress_priority = thread->depress_priority; +#if NCPUS > 1 + sched_info->last_processor = thread->last_processor; +#else + sched_info->last_processor = 0; +#endif + thread_unlock(thread); splx(s); -- cgit v1.2.3