3 // Copyright (C) 2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #define ENSC_WRAPPERS_PREFIX "vsched: "
32 #define ENSC_WRAPPERS_VSERVER 1
33 #define ENSC_WRAPPERS_UNISTD 1
36 #define CMD_HELP 0x1000
37 #define CMD_VERSION 0x1001
38 #define CMD_XID 0x4000
39 #define CMD_FRATE 0x4001
40 #define CMD_INTERVAL 0x4002
41 #define CMD_TOKENS 0x4003
42 #define CMD_TOK_MIN 0x4004
43 #define CMD_TOK_MAX 0x4005
44 #define CMD_CPU_MASK 0x4006
46 int wrapper_exit_code = 255;
50 { "help", no_argument, 0, CMD_HELP },
51 { "version", no_argument, 0, CMD_VERSION },
52 { "ctx", required_argument, 0, CMD_XID },
53 { "xid", required_argument, 0, CMD_XID },
54 { "fill-rate", required_argument, 0, CMD_FRATE },
55 { "interval", required_argument, 0, CMD_INTERVAL },
56 { "tokens", required_argument, 0, CMD_TOKENS },
57 { "tokens_min", required_argument, 0, CMD_TOK_MIN },
58 { "tokens_max", required_argument, 0, CMD_TOK_MAX },
59 { "cpu_mask", required_argument, 0, CMD_CPU_MASK },
64 showHelp(int fd, char const *cmd, int res)
66 VSERVER_DECLARE_CMD(cmd);
68 WRITE_MSG(fd, "Usage:\n ");
71 " [--xid <xid>] [--fill-rate <rate>] [--interval <interval>] [--tokens <tokens>] [--tokens_min <tokens>] [--tokens_max <tokens>] [--cpu_mask <mask>] [--] [<command> <args>*]\n"
73 "Please report bugs to " PACKAGE_BUGREPORT "\n");
82 "vsched " VERSION " -- modifies scheduling parameters\n"
83 "This program is part of " PACKAGE_STRING "\n\n"
84 "Copyright (C) 2003,2004 Enrico Scholz\n"
85 VERSION_COPYRIGHT_DISCLAIMER);
89 int main(int argc, char *argv[])
92 struct vc_set_sched sched = { 0,0,0,0,0,0 };
96 int c = getopt_long(argc, argv, "+", CMDLINE_OPTIONS, 0);
100 case CMD_HELP : showHelp(1, argv[0], 0);
101 case CMD_VERSION : showVersion();
102 case CMD_XID : xid = Evc_xidopt2xid(optarg,true); break;
103 case CMD_FRATE : sched.fill_rate = atoi(optarg); do_it = true; break;
104 case CMD_INTERVAL : sched.interval = atoi(optarg); do_it = true; break;
105 case CMD_TOKENS : sched.tokens = atoi(optarg); do_it = true; break;
106 case CMD_TOK_MIN : sched.tokens_min = atoi(optarg); do_it = true; break;
107 case CMD_TOK_MAX : sched.tokens_max = atoi(optarg); do_it = true; break;
108 case CMD_CPU_MASK : sched.cpu_mask = atoi(optarg); do_it = true; break;
110 WRITE_MSG(2, "Try '");
111 WRITE_STR(2, argv[0]);
112 WRITE_MSG(2, " --help\" for more information.\n");
118 if (xid==VC_NOCTX && optind==argc) {
119 WRITE_MSG(2, "Without a program, '--xid' must be used; try '--help' for more information\n");
120 exit(wrapper_exit_code);
123 if (!do_it && optind==argc) {
124 WRITE_MSG(2, "Neither an option nor a program was specified; try '--help' for more information\n");
125 exit(wrapper_exit_code);
129 xid = Evc_get_task_xid(0);
131 if (do_it && vc_set_sched(xid, &sched)==-1) {
132 perror("vc_set_sched()");
136 EexecvpD(argv[optind],argv+optind);