[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Test program for running task on slave_pset
From: |
Damien Zammit |
Subject: |
Test program for running task on slave_pset |
Date: |
Mon, 12 Feb 2024 05:53:12 +0000 |
Hi,
This program requires master branch PLUS
a one line patch I just mailed in for gnumach.
Here is a simple test program to enable
a new task to run on slave_pset processor set
containing the rest of the processors in SMP kernel.
You can compile it as a sutil in hurd/sutils:
usage must be run as root eg:
$ sudo /path/to/smp /bin/bash
# stress -c 7
Damien
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$ cat smp.c
/* Run a task on slave_pset
Copyright (C) 2024 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
The GNU Hurd is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2, or (at
your option) any later version.
The GNU Hurd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <error.h>
#include <hurd.h>
#include <version.h>
#include <mach/mach_types.h>
#include <mach/mach_host.h>
static void
smp(char * const argv[])
{
int err;
unsigned int pset_count;
mach_port_t hostpriv;
processor_set_name_array_t psets = {0};
processor_set_t slave_pset = {0};
if (get_privileged_ports (&hostpriv, NULL))
error (1, 0, "Must be run as root for privileged cpu control");
err = host_processor_sets (hostpriv, &psets, &pset_count);
if (err)
error (1, 0, "Cannot get list of host processor sets");
if (pset_count < 2)
error (1, 0, "gnumach does not have the expected processor sets,
are you running smp kernel?");
err = host_processor_set_priv (hostpriv, psets[1], &slave_pset);
if (err)
error (1, 0, "Cannot get access to slave processor set");
err = task_assign(mach_task_self(), slave_pset, FALSE);
if (err)
error (1, 0, "Cannot assign task self to slave processor set");
execve(argv[1], &argv[1], NULL);
/* NOT REACHED */
}
int
main (int argc, char **argv)
{
smp(argv);
return 0;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Test program for running task on slave_pset,
Damien Zammit <=