2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
29 * Mach Operating System
30 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
31 * All Rights Reserved.
33 * Permission to use, copy, modify and distribute this software and its
34 * documentation is hereby granted, provided that both the copyright
35 * notice and this permission notice appear in all copies of the
36 * software, derivative works or modified versions, and any portions
37 * thereof, and that both notices appear in supporting documentation.
39 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
40 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
41 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
43 * Carnegie Mellon requests users of this software to return to
45 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
46 * School of Computer Science
47 * Carnegie Mellon University
48 * Pittsburgh PA 15213-3890
50 * any improvements or extensions that they make and grant Carnegie Mellon
51 * the rights to redistribute these changes.
57 * processor.c: processor and processor_set manipulation routines.
62 #include <mach/boolean.h>
63 #include <mach/policy.h>
64 #include <mach/processor_info.h>
65 #include <mach/vm_param.h>
66 #include <kern/cpu_number.h>
67 #include <kern/host.h>
68 #include <kern/machine.h>
69 #include <kern/misc_protos.h>
70 #include <kern/processor.h>
71 #include <kern/sched.h>
72 #include <kern/task.h>
73 #include <kern/thread.h>
74 #include <kern/ipc_host.h>
75 #include <kern/ipc_tt.h>
76 #include <ipc/ipc_port.h>
77 #include <kern/kalloc.h>
82 #include <mach/mach_host_server.h>
87 struct processor_set default_pset
;
88 struct processor processor_array
[NCPUS
];
92 processor_t master_processor
;
93 processor_t processor_ptr
[NCPUS
];
97 processor_set_t pset
);
100 register processor_t pr
,
103 void pset_quanta_setup(
104 processor_set_t pset
);
106 kern_return_t
processor_set_base(
107 processor_set_t pset
,
112 kern_return_t
processor_set_limit(
113 processor_set_t pset
,
115 policy_limit_t limit
,
118 kern_return_t
processor_set_things(
119 processor_set_t pset
,
120 mach_port_t
**thing_list
,
121 mach_msg_type_number_t
*count
,
126 * Bootstrap the processor/pset system so the scheduler can run.
129 pset_sys_bootstrap(void)
133 pset_init(&default_pset
);
135 for (i
= 0; i
< NCPUS
; i
++) {
137 * Initialize processor data structures.
138 * Note that cpu_to_processor(i) is processor_ptr[i].
140 processor_ptr
[i
] = &processor_array
[i
];
141 processor_init(processor_ptr
[i
], i
);
144 master_processor
= cpu_to_processor(master_cpu
);
146 default_pset
.active
= TRUE
;
150 * Initialize the given processor_set structure.
154 register processor_set_t pset
)
158 /* setup run queue */
159 pset
->runq
.highq
= IDLEPRI
;
160 for (i
= 0; i
< NRQBM
; i
++)
161 pset
->runq
.bitmap
[i
] = 0;
162 setbit(MAXPRI
- IDLEPRI
, pset
->runq
.bitmap
);
163 pset
->runq
.urgency
= pset
->runq
.count
= 0;
164 for (i
= 0; i
< NRQS
; i
++)
165 queue_init(&pset
->runq
.queues
[i
]);
167 queue_init(&pset
->idle_queue
);
168 pset
->idle_count
= 0;
169 queue_init(&pset
->active_queue
);
170 simple_lock_init(&pset
->sched_lock
, ETAP_THREAD_PSET_IDLE
);
171 pset
->run_count
= pset
->share_count
= 0;
172 pset
->mach_factor
= pset
->load_average
= 0;
173 pset
->sched_load
= 0;
174 queue_init(&pset
->processors
);
175 pset
->processor_count
= 0;
176 queue_init(&pset
->tasks
);
177 pset
->task_count
= 0;
178 queue_init(&pset
->threads
);
179 pset
->thread_count
= 0;
181 pset
->active
= FALSE
;
182 mutex_init(&pset
->lock
, ETAP_THREAD_PSET
);
183 pset
->pset_self
= IP_NULL
;
184 pset
->pset_name_self
= IP_NULL
;
185 pset
->timeshare_quanta
= 1;
187 for (i
= 0; i
<= NCPUS
; i
++)
188 pset
->quantum_factors
[i
] = 1;
192 * Initialize the given processor structure for the processor in
193 * the slot specified by slot_num.
197 register processor_t p
,
202 /* setup run queue */
203 p
->runq
.highq
= IDLEPRI
;
204 for (i
= 0; i
< NRQBM
; i
++)
205 p
->runq
.bitmap
[i
] = 0;
206 setbit(MAXPRI
- IDLEPRI
, p
->runq
.bitmap
);
207 p
->runq
.urgency
= p
->runq
.count
= 0;
208 for (i
= 0; i
< NRQS
; i
++)
209 queue_init(&p
->runq
.queues
[i
]);
211 p
->state
= PROCESSOR_OFF_LINE
;
212 p
->active_thread
= p
->next_thread
= p
->idle_thread
= THREAD_NULL
;
213 p
->processor_set
= PROCESSOR_SET_NULL
;
214 p
->current_pri
= MINPRI
;
215 timer_call_setup(&p
->quantum_timer
, thread_quantum_expire
, p
);
217 p
->deadline
= UINT64_MAX
;
218 simple_lock_init(&p
->lock
, ETAP_THREAD_PROC
);
219 p
->processor_self
= IP_NULL
;
220 p
->slot_num
= slot_num
;
226 * Remove one reference to the processor set. Destroy processor_set
227 * if this was the last reference.
231 processor_set_t pset
)
233 if (pset
== PROCESSOR_SET_NULL
)
236 assert(pset
== &default_pset
);
243 * Add one reference to the processor set.
247 processor_set_t pset
)
249 assert(pset
== &default_pset
);
252 #define pset_reference_locked(pset) assert(pset == &default_pset)
255 * pset_remove_processor() removes a processor from a processor_set.
256 * It can only be called on the current processor. Caller must
257 * hold lock on current processor and processor set.
260 pset_remove_processor(
261 processor_set_t pset
,
262 processor_t processor
)
264 if (pset
!= processor
->processor_set
)
265 panic("pset_remove_processor: wrong pset");
267 queue_remove(&pset
->processors
, processor
, processor_t
, processors
);
268 processor
->processor_set
= PROCESSOR_SET_NULL
;
269 pset
->processor_count
--;
270 pset_quanta_setup(pset
);
274 * pset_add_processor() adds a processor to a processor_set.
275 * It can only be called on the current processor. Caller must
276 * hold lock on curent processor and on pset. No reference counting on
277 * processors. Processor reference to pset is implicit.
281 processor_set_t pset
,
282 processor_t processor
)
284 queue_enter(&pset
->processors
, processor
, processor_t
, processors
);
285 processor
->processor_set
= pset
;
286 pset
->processor_count
++;
287 pset_quanta_setup(pset
);
291 * pset_remove_task() removes a task from a processor_set.
292 * Caller must hold locks on pset and task (unless task has
293 * no references left, in which case just the pset lock is
294 * needed). Pset reference count is not decremented;
295 * caller must explicitly pset_deallocate.
299 processor_set_t pset
,
302 if (pset
!= task
->processor_set
)
305 queue_remove(&pset
->tasks
, task
, task_t
, pset_tasks
);
306 task
->processor_set
= PROCESSOR_SET_NULL
;
311 * pset_add_task() adds a task to a processor_set.
312 * Caller must hold locks on pset and task. Pset references to
313 * tasks are implicit.
317 processor_set_t pset
,
320 queue_enter(&pset
->tasks
, task
, task_t
, pset_tasks
);
321 task
->processor_set
= pset
;
323 pset_reference_locked(pset
);
327 * pset_remove_thread() removes a thread from a processor_set.
328 * Caller must hold locks on pset and thread (but only if thread
329 * has outstanding references that could be used to lookup the pset).
330 * The pset reference count is not decremented; caller must explicitly
335 processor_set_t pset
,
338 queue_remove(&pset
->threads
, thread
, thread_t
, pset_threads
);
339 thread
->processor_set
= PROCESSOR_SET_NULL
;
340 pset
->thread_count
--;
344 * pset_add_thread() adds a thread to a processor_set.
345 * Caller must hold locks on pset and thread. Pset references to
346 * threads are implicit.
350 processor_set_t pset
,
353 queue_enter(&pset
->threads
, thread
, thread_t
, pset_threads
);
354 thread
->processor_set
= pset
;
355 pset
->thread_count
++;
356 pset_reference_locked(pset
);
360 * thread_change_psets() changes the pset of a thread. Caller must
361 * hold locks on both psets and thread. The old pset must be
362 * explicitly pset_deallocat()'ed by caller.
367 processor_set_t old_pset
,
368 processor_set_t new_pset
)
370 queue_remove(&old_pset
->threads
, thread
, thread_t
, pset_threads
);
371 old_pset
->thread_count
--;
372 queue_enter(&new_pset
->threads
, thread
, thread_t
, pset_threads
);
373 thread
->processor_set
= new_pset
;
374 new_pset
->thread_count
++;
375 pset_reference_locked(new_pset
);
380 processor_info_count(
381 processor_flavor_t flavor
,
382 mach_msg_type_number_t
*count
)
387 case PROCESSOR_BASIC_INFO
:
388 *count
= PROCESSOR_BASIC_INFO_COUNT
;
390 case PROCESSOR_CPU_LOAD_INFO
:
391 *count
= PROCESSOR_CPU_LOAD_INFO_COUNT
;
394 kr
= cpu_info_count(flavor
, count
);
402 register processor_t processor
,
403 processor_flavor_t flavor
,
405 processor_info_t info
,
406 mach_msg_type_number_t
*count
)
408 register int i
, slot_num
, state
;
409 register processor_basic_info_t basic_info
;
410 register processor_cpu_load_info_t cpu_load_info
;
413 if (processor
== PROCESSOR_NULL
)
414 return(KERN_INVALID_ARGUMENT
);
416 slot_num
= processor
->slot_num
;
420 case PROCESSOR_BASIC_INFO
:
422 if (*count
< PROCESSOR_BASIC_INFO_COUNT
)
423 return(KERN_FAILURE
);
425 basic_info
= (processor_basic_info_t
) info
;
426 basic_info
->cpu_type
= machine_slot
[slot_num
].cpu_type
;
427 basic_info
->cpu_subtype
= machine_slot
[slot_num
].cpu_subtype
;
428 state
= processor
->state
;
429 if (state
== PROCESSOR_OFF_LINE
)
430 basic_info
->running
= FALSE
;
432 basic_info
->running
= TRUE
;
433 basic_info
->slot_num
= slot_num
;
434 if (processor
== master_processor
)
435 basic_info
->is_master
= TRUE
;
437 basic_info
->is_master
= FALSE
;
439 *count
= PROCESSOR_BASIC_INFO_COUNT
;
441 return(KERN_SUCCESS
);
443 case PROCESSOR_CPU_LOAD_INFO
:
445 if (*count
< PROCESSOR_CPU_LOAD_INFO_COUNT
)
446 return(KERN_FAILURE
);
448 cpu_load_info
= (processor_cpu_load_info_t
) info
;
449 for (i
=0;i
<CPU_STATE_MAX
;i
++)
450 cpu_load_info
->cpu_ticks
[i
] = machine_slot
[slot_num
].cpu_ticks
[i
];
452 *count
= PROCESSOR_CPU_LOAD_INFO_COUNT
;
454 return(KERN_SUCCESS
);
458 kr
=cpu_info(flavor
, slot_num
, info
, count
);
459 if (kr
== KERN_SUCCESS
)
468 processor_t processor
)
470 kern_return_t result
;
473 if (processor
== PROCESSOR_NULL
)
474 return(KERN_INVALID_ARGUMENT
);
476 if (processor
== master_processor
) {
479 prev
= thread_bind(current_thread(), processor
);
480 thread_block(THREAD_CONTINUE_NULL
);
482 result
= cpu_start(processor
->slot_num
);
484 thread_bind(current_thread(), prev
);
490 processor_lock(processor
);
491 if (processor
->state
!= PROCESSOR_OFF_LINE
) {
492 processor_unlock(processor
);
495 return (KERN_FAILURE
);
498 processor
->state
= PROCESSOR_START
;
499 processor_unlock(processor
);
502 if (processor
->next_thread
== THREAD_NULL
) {
504 extern void start_cpu_thread(void);
506 thread
= kernel_thread_create(start_cpu_thread
, MAXPRI_KERNEL
);
510 thread
->bound_processor
= processor
;
511 processor
->next_thread
= thread
;
512 thread
->state
= TH_RUN
;
513 pset_run_incr(thread
->processor_set
);
514 thread_unlock(thread
);
518 if (processor
->processor_self
== IP_NULL
)
519 ipc_processor_init(processor
);
521 result
= cpu_start(processor
->slot_num
);
522 if (result
!= KERN_SUCCESS
) {
524 processor_lock(processor
);
525 processor
->state
= PROCESSOR_OFF_LINE
;
526 processor_unlock(processor
);
532 ipc_processor_enable(processor
);
534 return (KERN_SUCCESS
);
539 processor_t processor
)
541 if (processor
== PROCESSOR_NULL
)
542 return(KERN_INVALID_ARGUMENT
);
544 return(processor_shutdown(processor
));
549 processor_t processor
,
550 processor_info_t info
,
551 mach_msg_type_number_t count
)
553 if (processor
== PROCESSOR_NULL
)
554 return(KERN_INVALID_ARGUMENT
);
556 return(cpu_control(processor
->slot_num
, info
, count
));
560 * Precalculate the appropriate timesharing quanta based on load. The
561 * index into quantum_factors[] is the number of threads on the
562 * processor set queue. It is limited to the number of processors in
568 processor_set_t pset
)
570 register int i
, count
= pset
->processor_count
;
572 for (i
= 1; i
<= count
; i
++)
573 pset
->quantum_factors
[i
] = (count
+ (i
/ 2)) / i
;
575 pset
->quantum_factors
[0] = pset
->quantum_factors
[1];
577 timeshare_quanta_update(pset
);
581 processor_set_create(
583 processor_set_t
*new_set
,
584 processor_set_t
*new_name
)
587 host
++; new_set
++; new_name
++;
589 return(KERN_FAILURE
);
593 processor_set_destroy(
594 processor_set_t pset
)
599 return(KERN_FAILURE
);
603 processor_get_assignment(
604 processor_t processor
,
605 processor_set_t
*pset
)
609 state
= processor
->state
;
610 if (state
== PROCESSOR_SHUTDOWN
|| state
== PROCESSOR_OFF_LINE
)
611 return(KERN_FAILURE
);
613 *pset
= processor
->processor_set
;
614 pset_reference(*pset
);
615 return(KERN_SUCCESS
);
620 processor_set_t pset
,
623 processor_set_info_t info
,
624 mach_msg_type_number_t
*count
)
626 if (pset
== PROCESSOR_SET_NULL
)
627 return(KERN_INVALID_ARGUMENT
);
629 if (flavor
== PROCESSOR_SET_BASIC_INFO
) {
630 register processor_set_basic_info_t basic_info
;
632 if (*count
< PROCESSOR_SET_BASIC_INFO_COUNT
)
633 return(KERN_FAILURE
);
635 basic_info
= (processor_set_basic_info_t
) info
;
636 basic_info
->processor_count
= pset
->processor_count
;
637 basic_info
->default_policy
= POLICY_TIMESHARE
;
639 *count
= PROCESSOR_SET_BASIC_INFO_COUNT
;
641 return(KERN_SUCCESS
);
643 else if (flavor
== PROCESSOR_SET_TIMESHARE_DEFAULT
) {
644 register policy_timeshare_base_t ts_base
;
646 if (*count
< POLICY_TIMESHARE_BASE_COUNT
)
647 return(KERN_FAILURE
);
649 ts_base
= (policy_timeshare_base_t
) info
;
650 ts_base
->base_priority
= BASEPRI_DEFAULT
;
652 *count
= POLICY_TIMESHARE_BASE_COUNT
;
654 return(KERN_SUCCESS
);
656 else if (flavor
== PROCESSOR_SET_FIFO_DEFAULT
) {
657 register policy_fifo_base_t fifo_base
;
659 if (*count
< POLICY_FIFO_BASE_COUNT
)
660 return(KERN_FAILURE
);
662 fifo_base
= (policy_fifo_base_t
) info
;
663 fifo_base
->base_priority
= BASEPRI_DEFAULT
;
665 *count
= POLICY_FIFO_BASE_COUNT
;
667 return(KERN_SUCCESS
);
669 else if (flavor
== PROCESSOR_SET_RR_DEFAULT
) {
670 register policy_rr_base_t rr_base
;
672 if (*count
< POLICY_RR_BASE_COUNT
)
673 return(KERN_FAILURE
);
675 rr_base
= (policy_rr_base_t
) info
;
676 rr_base
->base_priority
= BASEPRI_DEFAULT
;
677 rr_base
->quantum
= 1;
679 *count
= POLICY_RR_BASE_COUNT
;
681 return(KERN_SUCCESS
);
683 else if (flavor
== PROCESSOR_SET_TIMESHARE_LIMITS
) {
684 register policy_timeshare_limit_t ts_limit
;
686 if (*count
< POLICY_TIMESHARE_LIMIT_COUNT
)
687 return(KERN_FAILURE
);
689 ts_limit
= (policy_timeshare_limit_t
) info
;
690 ts_limit
->max_priority
= MAXPRI_STANDARD
;
692 *count
= POLICY_TIMESHARE_LIMIT_COUNT
;
694 return(KERN_SUCCESS
);
696 else if (flavor
== PROCESSOR_SET_FIFO_LIMITS
) {
697 register policy_fifo_limit_t fifo_limit
;
699 if (*count
< POLICY_FIFO_LIMIT_COUNT
)
700 return(KERN_FAILURE
);
702 fifo_limit
= (policy_fifo_limit_t
) info
;
703 fifo_limit
->max_priority
= MAXPRI_STANDARD
;
705 *count
= POLICY_FIFO_LIMIT_COUNT
;
707 return(KERN_SUCCESS
);
709 else if (flavor
== PROCESSOR_SET_RR_LIMITS
) {
710 register policy_rr_limit_t rr_limit
;
712 if (*count
< POLICY_RR_LIMIT_COUNT
)
713 return(KERN_FAILURE
);
715 rr_limit
= (policy_rr_limit_t
) info
;
716 rr_limit
->max_priority
= MAXPRI_STANDARD
;
718 *count
= POLICY_RR_LIMIT_COUNT
;
720 return(KERN_SUCCESS
);
722 else if (flavor
== PROCESSOR_SET_ENABLED_POLICIES
) {
723 register int *enabled
;
725 if (*count
< (sizeof(*enabled
)/sizeof(int)))
726 return(KERN_FAILURE
);
728 enabled
= (int *) info
;
729 *enabled
= POLICY_TIMESHARE
| POLICY_RR
| POLICY_FIFO
;
731 *count
= sizeof(*enabled
)/sizeof(int);
733 return(KERN_SUCCESS
);
738 return(KERN_INVALID_ARGUMENT
);
742 * processor_set_statistics
744 * Returns scheduling statistics for a processor set.
747 processor_set_statistics(
748 processor_set_t pset
,
750 processor_set_info_t info
,
751 mach_msg_type_number_t
*count
)
753 if (pset
== PROCESSOR_SET_NULL
)
754 return (KERN_INVALID_PROCESSOR_SET
);
756 if (flavor
== PROCESSOR_SET_LOAD_INFO
) {
757 register processor_set_load_info_t load_info
;
759 if (*count
< PROCESSOR_SET_LOAD_INFO_COUNT
)
760 return(KERN_FAILURE
);
762 load_info
= (processor_set_load_info_t
) info
;
765 load_info
->task_count
= pset
->task_count
;
766 load_info
->thread_count
= pset
->thread_count
;
767 load_info
->mach_factor
= pset
->mach_factor
;
768 load_info
->load_average
= pset
->load_average
;
771 *count
= PROCESSOR_SET_LOAD_INFO_COUNT
;
772 return(KERN_SUCCESS
);
775 return(KERN_INVALID_ARGUMENT
);
779 * processor_set_max_priority:
781 * Specify max priority permitted on processor set. This affects
782 * newly created and assigned threads. Optionally change existing
786 processor_set_max_priority(
787 processor_set_t pset
,
789 boolean_t change_threads
)
791 return (KERN_INVALID_ARGUMENT
);
795 * processor_set_policy_enable:
797 * Allow indicated policy on processor set.
801 processor_set_policy_enable(
802 processor_set_t pset
,
805 return (KERN_INVALID_ARGUMENT
);
809 * processor_set_policy_disable:
811 * Forbid indicated policy on processor set. Time sharing cannot
815 processor_set_policy_disable(
816 processor_set_t pset
,
818 boolean_t change_threads
)
820 return (KERN_INVALID_ARGUMENT
);
824 #define THING_THREAD 1
827 * processor_set_things:
829 * Common internals for processor_set_{threads,tasks}
832 processor_set_things(
833 processor_set_t pset
,
834 mach_port_t
**thing_list
,
835 mach_msg_type_number_t
*count
,
838 unsigned int actual
; /* this many things */
841 vm_size_t size
, size_needed
;
844 if (pset
== PROCESSOR_SET_NULL
)
845 return KERN_INVALID_ARGUMENT
;
856 if (type
== THING_TASK
)
857 actual
= pset
->task_count
;
859 actual
= pset
->thread_count
;
861 /* do we have the memory we need? */
863 size_needed
= actual
* sizeof(mach_port_t
);
864 if (size_needed
<= size
)
867 /* unlock the pset and allocate more memory */
873 assert(size_needed
> 0);
878 return KERN_RESOURCE_SHORTAGE
;
881 /* OK, have memory and the processor_set is locked & active */
885 task_t
*tasks
= (task_t
*) addr
;
888 for (i
= 0, task
= (task_t
) queue_first(&pset
->tasks
);
889 !queue_end(&pset
->tasks
, (queue_entry_t
) task
);
890 task
= (task_t
) queue_next(&task
->pset_tasks
)) {
893 if (task
->ref_count
> 0) {
894 /* take ref for convert_task_to_port */
895 task_reference_locked(task
);
904 thread_act_t
*thr_acts
= (thread_act_t
*) addr
;
906 thread_act_t thr_act
;
908 for (i
= 0, thread
= (thread_t
) queue_first(&pset
->threads
);
909 !queue_end(&pset
->threads
, (queue_entry_t
)thread
);
910 thread
= (thread_t
) queue_next(&thread
->pset_threads
)) {
912 thr_act
= thread_lock_act(thread
);
913 if (thr_act
&& thr_act
->act_ref_count
> 0) {
914 /* take ref for convert_act_to_port */
915 act_reference_locked(thr_act
);
916 thr_acts
[i
++] = thr_act
;
918 thread_unlock_act(thread
);
924 /* can unlock processor set now that we have the task/thread refs */
929 size_needed
= actual
* sizeof(mach_port_t
);
934 /* no things, so return null pointer and deallocate memory */
941 /* if we allocated too much, must copy */
943 if (size_needed
< size
) {
946 newaddr
= kalloc(size_needed
);
950 task_t
*tasks
= (task_t
*) addr
;
952 for (i
= 0; i
< actual
; i
++)
953 task_deallocate(tasks
[i
]);
958 thread_act_t
*acts
= (thread_act_t
*) addr
;
960 for (i
= 0; i
< actual
; i
++)
961 act_deallocate(acts
[i
]);
966 return KERN_RESOURCE_SHORTAGE
;
969 bcopy((char *) addr
, (char *) newaddr
, size_needed
);
974 *thing_list
= (mach_port_t
*) addr
;
977 /* do the conversion that Mig should handle */
981 task_t
*tasks
= (task_t
*) addr
;
983 for (i
= 0; i
< actual
; i
++)
984 (*thing_list
)[i
] = convert_task_to_port(tasks
[i
]);
989 thread_act_t
*thr_acts
= (thread_act_t
*) addr
;
991 for (i
= 0; i
< actual
; i
++)
992 (*thing_list
)[i
] = convert_act_to_port(thr_acts
[i
]);
998 return(KERN_SUCCESS
);
1003 * processor_set_tasks:
1005 * List all tasks in the processor set.
1008 processor_set_tasks(
1009 processor_set_t pset
,
1010 task_array_t
*task_list
,
1011 mach_msg_type_number_t
*count
)
1013 return(processor_set_things(pset
, (mach_port_t
**)task_list
, count
, THING_TASK
));
1017 * processor_set_threads:
1019 * List all threads in the processor set.
1022 processor_set_threads(
1023 processor_set_t pset
,
1024 thread_array_t
*thread_list
,
1025 mach_msg_type_number_t
*count
)
1027 return(processor_set_things(pset
, (mach_port_t
**)thread_list
, count
, THING_THREAD
));
1031 * processor_set_base:
1033 * Specify per-policy base priority for a processor set. Set processor
1034 * set default policy to the given policy. This affects newly created
1035 * and assigned threads. Optionally change existing ones.
1039 processor_set_t pset
,
1044 return (KERN_INVALID_ARGUMENT
);
1048 * processor_set_limit:
1050 * Specify per-policy limits for a processor set. This affects
1051 * newly created and assigned threads. Optionally change existing
1055 processor_set_limit(
1056 processor_set_t pset
,
1058 policy_limit_t limit
,
1061 return (KERN_POLICY_LIMIT
);
1065 * processor_set_policy_control
1067 * Controls the scheduling attributes governing the processor set.
1068 * Allows control of enabled policies, and per-policy base and limit
1072 processor_set_policy_control(
1073 processor_set_t pset
,
1075 processor_set_info_t policy_info
,
1076 mach_msg_type_number_t count
,
1079 return (KERN_INVALID_ARGUMENT
);