github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/include/scheduler.h (about) 1 /* 2 * Copyright (c) 2013 Intel Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * Unless required by applicable law or agreed to in writing, software 9 * distributed under the License is distributed on an "AS IS" BASIS, 10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 * See the License for the specific language governing permissions and 12 * limitations under the License. 13 */ 14 15 #ifndef _SCHEDULER_H_ 16 #define _SCHEDULER_H_ 17 18 #include "vmm_defs.h" 19 #include "hw_includes.h" 20 #include "guest_cpu.h" 21 #include "libc.h" 22 #include "vmm_objects.h" 23 24 25 // Get current 26 // Return NULL if no guest cpu is running on current host cpu 27 GUEST_CPU_HANDLE scheduler_current_gcpu( void ); 28 29 // Get Host CPU Id for which given Guest CPU is assigned 30 UINT16 scheduler_get_host_cpu_id( GUEST_CPU_HANDLE gcpu ); 31 32 // Enumerate Guest CPUs assigned to the same Host CPU 33 // Return NULL to indicate end of enumeration 34 35 // user allocated enumeration context 36 typedef struct _SCHEDULER_VCPU_OBJECT* SCHEDULER_GCPU_ITERATOR; 37 38 GUEST_CPU_HANDLE 39 scheduler_same_host_cpu_gcpu_first( SCHEDULER_GCPU_ITERATOR* ctx, 40 CPU_ID host_cpu_id ); 41 42 GUEST_CPU_HANDLE 43 scheduler_same_host_cpu_gcpu_next( SCHEDULER_GCPU_ITERATOR* ctx ); 44 45 // Determine initial gCPU to run on the current host CPU 46 // Makes selected gCPU "current" on the current host CPU and returns it. 47 // If no ready vcpus on the current host CPU, returns NULL 48 GUEST_CPU_HANDLE scheduler_select_initial_gcpu( void ); 49 50 // Determine next gCPU to run on the current host CPU 51 // Makes selected gCPU "current" on the current host CPU and returns it. 52 // If no ready vcpus on the current host CPU, returns NULL 53 // Note: 54 // 1. scheduler_select_initial_gcpu() should be called before on this host 55 // CPU 56 GUEST_CPU_HANDLE scheduler_select_next_gcpu( void ); 57 58 GUEST_CPU_HANDLE scheduler_schedule_gcpu( GUEST_CPU_HANDLE gcpu ); 59 60 61 // init scheduler. 62 void scheduler_init( UINT16 number_of_host_cpus ); 63 64 // register guest cpu 65 void scheduler_register_gcpu( GUEST_CPU_HANDLE gcpu_handle, 66 CPU_ID host_cpu_id, BOOLEAN schedule_immediately ); 67 68 69 GUEST_CPU_HANDLE scheduler_get_current_gcpu_for_guest( GUEST_ID guest_id ); 70 71 #ifdef INCLUDE_UNUSED_CODE 72 GUEST_CPU_HANDLE scheduler_get_current_gcpu_on_host_cpu( CPU_ID host_cpu_id ); 73 #endif 74 75 #endif // _SCHEDULER_H_ 76