1 /* Support code for dealing with priorities in the Hurd.
2 Copyright (C) 1994 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 Cambridge, MA 02139, USA. */
20 #include <hurd/resource.h>
24 _hurd_priority_which_map (enum __priority_which which
, int who
,
25 error_t (*function
) (pid_t
, struct procinfo
*))
27 mach_msg_type_number_t npids
= 64, i
;
28 pid_t pidbuf
[npids
], *pids
;
31 int pibuf
[sizeof *pip
+ 5 * sizeof (pip
->threadinfos
[0])], *pi
= pibuf
;
32 mach_msg_type_number_t pisize
= sizeof (pibuf
) / sizeof (int);
43 err
= __USEPORT (PROC
, __proc_getpgrppids (port
, who
, &pids
, &npids
));
47 err
= __USEPORT (PROC
, __proc_getallpids (port
, &pids
, &npids
));
54 for (i
= 0; !err
&& i
< npids
; ++i
)
56 if (which
== PRIO_USER
)
58 /* Get procinfo to check the owner. */
60 mach_msg_type_number_t oldpisize
= pisize
;
61 if (err
= __USEPORT (PROC
, __proc_getprocinfo (port
, pids
[i
],
64 if (pi
!= oldpi
&& oldpi
!= pibuf
)
65 /* Old buffer from last call was not reused; free it. */
66 __vm_deallocate (__mach_task_self (),
67 (vm_address_t
) oldpi
, oldpisize
* sizeof pi
[0]);
69 pip
= (struct procinfo
*) pi
;
70 if (pip
->owner
!= who
)
76 err
= (*function
) (pids
[i
], pip
);
80 __vm_deallocate (__mach_task_self (),
81 (vm_address_t
) pids
, npids
* sizeof pids
[0]);
83 __vm_deallocate (__mach_task_self (),
84 (vm_address_t
) pi
, pisize
* sizeof pi
[0]);