|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* ! 23: * @OSF_COPYRIGHT@ ! 24: * ! 25: */ ! 26: ! 27: #include <kern/misc_protos.h> ! 28: #include <kern/sf.h> ! 29: #include <kern/processor.h> ! 30: #include <kern/mk_sp.h> ! 31: #include <mach/policy.h> ! 32: ! 33: /* ! 34: * Procedure Prototypes ! 35: */ ! 36: ! 37: void sf_update_max_sizes( ! 38: sp_info_size_t info_size, ! 39: sp_attributes_size_t attributes_size); ! 40: ! 41: /* ! 42: * The array of scheduling policies supported by the Scheduling Framework. ! 43: */ ! 44: ! 45: sched_policy_t sched_policy[MAX_SCHED_POLS]; ! 46: ! 47: /* ! 48: * Maximum sizes for scheduling-policy-specific information and ! 49: * attributes, calculated dynamically based on the scheduling ! 50: * policies that are initialized at system startup time. ! 51: */ ! 52: sp_info_size_t max_sched_info_size = 0; ! 53: sp_attributes_size_t max_sched_attributes_size = 0; ! 54: ! 55: void ! 56: sf_init(void) ! 57: { ! 58: int i; ! 59: sf_return_t sfr; ! 60: sf_priority_mask pri_mask; ! 61: processor_t myprocessor; ! 62: processor_set_t pset; ! 63: extern struct processor_set default_pset; ! 64: ! 65: /* initialize scheduling framework */ ! 66: /*** XXX should this be done once for each node? ***/ ! 67: ! 68: /* ! 69: * Initialize scheduling policies. Each policy has its ! 70: * standard operation vector initialized and then has a ! 71: * routine called to initialize its internal state. ! 72: */ ! 73: /*** XXX should this be moved to `sched_init()' -- or it to here? ***/ ! 74: /*** XXX should this be done once for each CPU? ***/ ! 75: ! 76: /* ! 77: * Set up metapriority mask that will be used by the standard ! 78: * MK scheduling policies. ! 79: */ ! 80: for (i=0; i < NRQS; i++) { ! 81: setbit(i, pri_mask.bitmap); ! 82: } ! 83: clrbit(MAXPRI - LPRI + 1, pri_mask.bitmap); ! 84: clrbit(MAXPRI - LPRI, pri_mask.bitmap); ! 85: ! 86: /* Initialize standard MK Timesharing policy */ ! 87: sched_policy[POLICY_TIMESHARE].sp_ops = mk_sp_ops; ! 88: sfr = sched_policy[POLICY_TIMESHARE]. ! 89: sp_ops.sp_init( ! 90: &sched_policy[POLICY_TIMESHARE], POLICY_TIMESHARE, ! 91: sizeof(sf_priority_mask), &pri_mask); ! 92: if (sfr != SF_SUCCESS) { ! 93: printf("TIMESHARE failed to init: %d\n", sfr); ! 94: panic("sf_init"); ! 95: } ! 96: ! 97: sf_update_max_sizes(sched_policy[POLICY_TIMESHARE].sched_info_size, ! 98: sched_policy[POLICY_TIMESHARE].sched_attributes_size); ! 99: ! 100: /* Initialize standard MK Round Robin policy */ ! 101: sched_policy[POLICY_RR].sp_ops = mk_sp_ops; ! 102: sfr = sched_policy[POLICY_RR]. ! 103: sp_ops.sp_init( ! 104: &sched_policy[POLICY_RR], POLICY_RR, ! 105: sizeof(sf_priority_mask), &pri_mask); ! 106: if (sfr != SF_SUCCESS) { ! 107: printf("RR failed to init: %d\n", sfr); ! 108: panic("sf_init"); ! 109: } ! 110: ! 111: sf_update_max_sizes(sched_policy[POLICY_RR].sched_info_size, ! 112: sched_policy[POLICY_RR].sched_attributes_size); ! 113: ! 114: /* Initialize standard MK FIFO policy */ ! 115: sched_policy[POLICY_FIFO].sp_ops = mk_sp_ops; ! 116: sfr = sched_policy[POLICY_FIFO]. ! 117: sp_ops.sp_init( ! 118: &sched_policy[POLICY_FIFO], POLICY_FIFO, ! 119: sizeof(sf_priority_mask), &pri_mask); ! 120: if (sfr != SF_SUCCESS) { ! 121: printf("FIFO failed to init: %d\n", sfr); ! 122: panic("sf_init"); ! 123: } ! 124: ! 125: sf_update_max_sizes(sched_policy[POLICY_FIFO].sched_info_size, ! 126: sched_policy[POLICY_FIFO].sched_attributes_size); ! 127: ! 128: /* Enable the MK Timesharing policy on the current processor set */ ! 129: myprocessor = cpu_to_processor(cpu_number()); ! 130: pset = myprocessor->processor_set; ! 131: /*** XXX fix me ***/ ! 132: if (pset == PROCESSOR_SET_NULL) ! 133: pset = &default_pset; ! 134: ! 135: sched_policy[POLICY_TIMESHARE]. ! 136: sp_ops.sp_enable_processor_set( ! 137: &sched_policy[POLICY_TIMESHARE], pset); ! 138: } ! 139: ! 140: void ! 141: sf_update_max_sizes( ! 142: sp_info_size_t info_size, ! 143: sp_attributes_size_t attributes_size) ! 144: { ! 145: /* Update maximum values (individually) based on new sizes */ ! 146: if (info_size > max_sched_info_size) ! 147: max_sched_info_size = info_size; ! 148: if (attributes_size > max_sched_attributes_size) ! 149: max_sched_attributes_size = attributes_size; ! 150: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.