[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH hurd 2/9] proc: gracefully handle failure to increase priorit
From: |
Samuel Thibault |
Subject: |
Re: [PATCH hurd 2/9] proc: gracefully handle failure to increase priority |
Date: |
Fri, 21 Nov 2014 01:35:42 +0100 |
User-agent: |
Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) |
Justus Winter, le Fri 07 Nov 2014 17:31:55 +0100, a écrit :
> * proc/main.c (increase_priority): New function.
> (main): Move code increasing the proc servers priority to a new
> function and handle errors gracefully.
Ack.
> ---
> proc/main.c | 44 ++++++++++++++++++++++++++++++++------------
> 1 file changed, 32 insertions(+), 12 deletions(-)
>
> diff --git a/proc/main.c b/proc/main.c
> index f1f4e1b..3419d44 100644
> --- a/proc/main.c
> +++ b/proc/main.c
> @@ -60,12 +60,40 @@ message_demuxer (mach_msg_header_t *inp,
>
> pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER;
>
> +error_t
> +increase_priority (void)
> +{
> + mach_port_t pset = MACH_PORT_NULL, psetcntl = MACH_PORT_NULL;
> + error_t err;
> +
> + err = thread_get_assignment (mach_thread_self (), &pset);
> + if (err)
> + goto out;
> +
> + err = host_processor_set_priv (_hurd_host_priv, pset, &psetcntl);
> + if (err)
> + goto out;
> +
> + err = thread_max_priority (mach_thread_self (), psetcntl, 0);
> + if (err)
> + goto out;
> +
> + err = task_priority (mach_task_self (), 2, 1);
> +
> + out:
> + if (MACH_PORT_VALID (pset))
> + mach_port_deallocate (mach_task_self (), pset);
> + if (MACH_PORT_VALID (psetcntl))
> + mach_port_deallocate (mach_task_self (), psetcntl);
> +
> + return err;
> +}
> +
> int
> main (int argc, char **argv, char **envp)
> {
> mach_port_t boot;
> error_t err;
> - mach_port_t pset, psetcntl;
> void *genport;
> process_t startup_port;
> struct argp argp = { 0, 0, 0, "Hurd process server" };
> @@ -120,17 +148,9 @@ main (int argc, char **argv, char **envp)
>
> /* Give ourselves good scheduling performance, because we are so
> important. */
> - err = thread_get_assignment (mach_thread_self (), &pset);
> - assert_perror (err);
> - err = host_processor_set_priv (_hurd_host_priv, pset, &psetcntl);
> - assert_perror (err);
> - thread_max_priority (mach_thread_self (), psetcntl, 0);
> - assert_perror (err);
> - err = task_priority (mach_task_self (), 2, 1);
> - assert_perror (err);
> -
> - mach_port_deallocate (mach_task_self (), pset);
> - mach_port_deallocate (mach_task_self (), psetcntl);
> + err = increase_priority ();
> + if (err)
> + error (0, err, "Increasing priority failed");
>
> {
> /* Get our stderr set up to print on the console, in case we have
> --
> 2.1.1
>
--
Samuel
«Le monochrome, c'est pour ceux qui s'intéressent (encore) au contenu.
Usenet dans ces conditions, c'est comme le web avec lynx, on prend
trop conscience du vide, c'est déprimant.»
-+- JLC in Guide du linuxien pervers : "Coup de cafard..." -+-
- [PATCH hurd 1/9] Makeconf: handle the gnumach protocol, Justus Winter, 2014/11/07
- [PATCH hurd 2/9] proc: gracefully handle failure to increase priority, Justus Winter, 2014/11/07
- Re: [PATCH hurd 2/9] proc: gracefully handle failure to increase priority,
Samuel Thibault <=
- [PATCH hurd 3/9] startup: also open `console' for reading, Justus Winter, 2014/11/07
- [PATCH hurd 4/9] boot: drop bootstrap compat code, Justus Winter, 2014/11/07
- [PATCH hurd 5/9] boot: remove unused function `boot_script_read_file', Justus Winter, 2014/11/07
- [PATCH hurd 6/9] boot: drop obsolete device procedures, Justus Winter, 2014/11/07
- [PATCH hurd 7/9] boot: support ds_device_get_status with flavor DEV_GET_RECORDS, Justus Winter, 2014/11/07