diff options
author | Flavio Cruz <flaviocruz@gmail.com> | 2023-04-17 00:46:36 -0400 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-04-27 02:34:45 +0200 |
commit | f9a76508ab2e0b54af753fb017838857a059b3c6 (patch) | |
tree | da58667bd732cd99e60820a5d89c0792a7bcd422 /kern | |
parent | 2be047b97235796b9d4a5a51566d252384afc06e (diff) | |
download | gnumach-f9a76508ab2e0b54af753fb017838857a059b3c6.tar.gz gnumach-f9a76508ab2e0b54af753fb017838857a059b3c6.tar.bz2 gnumach-f9a76508ab2e0b54af753fb017838857a059b3c6.zip |
Update task_basic_info and thread_basic_info to include time_value64_t data.
RPCs remain compatible with existing clients but if they know about the
new size then we will populate the new fields.
Message-Id: <ZDzPLCJccKeRB5Pd@mars.tail36e24.ts.net>
Diffstat (limited to 'kern')
-rw-r--r-- | kern/task.c | 16 | ||||
-rw-r--r-- | kern/thread.c | 16 |
2 files changed, 23 insertions, 9 deletions
diff --git a/kern/task.c b/kern/task.c index 65191f5d..9492b448 100644 --- a/kern/task.c +++ b/kern/task.c @@ -787,13 +787,13 @@ kern_return_t task_info( { task_basic_info_t basic_info; - /* Allow *task_info_count to be two words smaller than - the usual amount, because creation_time is a new member - that some callers might not know about. */ + /* Allow *task_info_count to be smaller than the provided amount + * that does not contain the new time_value64_t fields as some + * callers might not know about them yet. */ - if (*task_info_count < TASK_BASIC_INFO_COUNT - 2) { + if (*task_info_count < + TASK_BASIC_INFO_COUNT - 3 * sizeof(time_value64_t)/sizeof(integer_t)) return KERN_INVALID_ARGUMENT; - } basic_info = (task_basic_info_t) task_info_out; @@ -813,6 +813,12 @@ kern_return_t task_info( time_value64_t creation_time64; read_time_stamp(&task->creation_time, &creation_time64); TIME_VALUE64_TO_TIME_VALUE(&creation_time64, &basic_info->creation_time); + if (*task_info_count == TASK_BASIC_INFO_COUNT) { + /* Copy new time_value64_t fields */ + basic_info->user_time64 = task->total_user_time; + basic_info->system_time64 = task->total_system_time; + basic_info->creation_time64 = creation_time64; + } task_unlock(task); if (*task_info_count > TASK_BASIC_INFO_COUNT) diff --git a/kern/thread.c b/kern/thread.c index 392d38f8..20c11024 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -1501,11 +1501,12 @@ kern_return_t thread_info( if (flavor == THREAD_BASIC_INFO) { thread_basic_info_t basic_info; - /* Allow *thread_info_count to be one smaller than the - usual amount, because creation_time is a new member - that some callers might not know about. */ + /* Allow *thread_info_count to be smaller than the provided amount + * that does not contain the new time_value64_t fields as some + * callers might not know about them yet. */ - if (*thread_info_count < THREAD_BASIC_INFO_COUNT - 1) + if (*thread_info_count < + THREAD_BASIC_INFO_COUNT - 3 * sizeof(time_value64_t)/sizeof(natural_t)) return KERN_INVALID_ARGUMENT; basic_info = (thread_basic_info_t) thread_info_out; @@ -1533,6 +1534,13 @@ kern_return_t thread_info( read_time_stamp(&thread->creation_time, &creation_time); TIME_VALUE64_TO_TIME_VALUE(&creation_time, &basic_info->creation_time); + if (*thread_info_count == THREAD_BASIC_INFO_COUNT) { + /* Copy new time_value64_t fields */ + basic_info->user_time64 = user_time; + basic_info->system_time64 = user_time; + basic_info->creation_time64 = creation_time; + } + /* * To calculate cpu_usage, first correct for timer rate, * then for 5/8 ageing. The correction factor [3/5] is |