⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 migrate.c

📁 OpenMosix工具
💻 C
字号:
/* Copyright (c) 2006 David Santo Orcero irbis@orcero.org               *//*  irbis@orcero.org  http://www.orcero.org/irbis                       *//* Code derived from previous work by Ariel Rosenblatt, Amnon Shiloh    *//* and Oren Laadan.                                                     *//* Mosix is (c) of prof. Amnon Barak http://www.mosix.org               *//* Original Mosix code is (c) of prof. Amnon Barak http://www.mosix.org *//* OpenMosix is (c) of Moshe Bar http://www.openmosix.com               *//* Each respective trademark is of its own owner                        *//* All rights reserved.                                                 *//* This software is distributed under GPL 2                             *//* THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTY IS ASSUMED.               *//* NO LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING            *//* FROM THE USE OF THIS SOFTWARE WILL BE ACCEPTED. IT CAN BURN              *//* YOUR HARD DISK, ERASE ALL YOUR DATA AND BROKE DOWN YOUR                  *//* MICROWAVE OVEN. YOU ARE ADVISED.                                         */#include <stdio.h>#include <string.h>#include <errno.h>#include <sys/signal.h>#include <sys/types.h>#include <sys/param.h>#include <sys/time.h>#include <mos.h>#include <libbalancer.h>intmain (int na, char *argv[]){  char *prog = (na && strchr (argv[0], '/')) ? strchr (argv[0], '/') + 1 :    (na ? argv[0] : "");  struct process_info a;#if _KERNELMAINVERI == 240  if (!msx_is_mosix ())    {      fprintf (stderr, "migrate ignored: This is not a OpenMosix system!\n");      exit (1);    }#elif _KERNELMAINVERI == 260  a.baseorder = DM_UNKNOWN;  if (!om_isopenmosix ())    {      fprintf (stderr, "migrate ignored: This is not a OpenMosix system!\n");      exit (1);    }#else#error Please set KERNELMAINVER to 2.4 or 2.6#endif    if (na != 3 || (a.pid = atoi (argv[1])) <= 0)      goto Usage;  switch (argv[2][0])    {    case '0':    case '1':    case '2':    case '3':    case '4':    case '5':    case '6':    case '7':    case '8':    case '9':#if _KERNELMAINVERI == 240      if ((a.where = atoi (argv[2])) < 0)	goto Usage;#elif _KERNELMAINVERI == 260      a.baseorder = DM_MANUAL_MIGRATION;      a.where = argv[2];      if (a.where == NULL)	goto Usage;#endif    case 'h':    case 'H':#if _KERNELMAINVERI == 240      a.where = DM_GOBACKHOME;#elif _KERNELMAINVERI == 260      a.baseorder = DM_GOBACKHOME;#endif      break;    case 'b':    case 'B':#if _KERNELMAINVERI == 240      a.where = DM_BALANCE;#elif _KERNELMAINVERI == 260      a.baseorder = DM_BALANCE_DEFAULT;#endif      break;    default:    Usage:      printf ("Usage: %s pid {OpenMosix-ID|home|balance}\n", prog);      exit (1);    }#if _KERNELMAINVERI == 240  if (msxctl2 (D_SETWHERETO, (int) &a) == -1)    {#endif#if _KERNELMAINVERI == 260  if (om_goto_node (a.baseorder, a.pid, a.where) == -1)    {#endif      fprintf (stderr, "%s: ", prog);      switch (errno)	{	case EPERM:	  fprintf (stderr, "Permission denied.\n");	  break;	case EBUSY:	  fprintf (stderr, "Process was already sent elsewhere.\n");	  break;	case ESRCH:	  fprintf (stderr, "No such process (%d).\n", a.pid);	  break;	case EROFS:	  fprintf (stderr, "Process #%d is unmovable.\n", a.pid);	  break;	default:	  fprintf (stderr, "%s.\n", strerror (errno));	}      return -1;    }  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -