prev_ptr = rp; /* store ptr for next */
}
-#if 0
- if (priv(rp)->s_flags & BILLABLE) { /* user process */
- }
- else { /* system process */
- }
-#endif
-
/* Determine the new priority of this process. The bounds are determined
* by IDLE's queue and the maximum priority of this process. Kernel task
* and the idle process are never changed in priority.
*/
- if (! iskernelp(rp) && penalty != 0) {
+ if (penalty != 0 && ! iskernelp(rp)) {
rp->p_priority += penalty; /* update with penalty */
if (rp->p_priority < rp->p_max_priority) /* check upper bound */
rp->p_priority=rp->p_max_priority;
PUBLIC char *t_stack[TOT_STACK_SPACE / sizeof(char *)];
/* Define flags for the various process types. */
-#define IDL_F (SYS_PROC | PREEMPTIBLE | BILLABLE) /* idle task */
-#define TSK_F (SYS_PROC) /* kernel tasks */
-#define SRV_F (SYS_PROC | PREEMPTIBLE) /* system services */
-#define USR_F (BILLABLE | PREEMPTIBLE) /* user processes */
+#define IDL_F (SYS_PROC | PREEMPTIBLE | BILLABLE) /* idle task */
+#define TSK_F (SYS_PROC) /* kernel tasks */
+#define SRV_F (SYS_PROC | PREEMPTIBLE) /* system services */
+#define USR_F (BILLABLE | PREEMPTIBLE) /* user processes */
/* Define system call traps for the various process types. These call masks
* determine what system call traps a process is allowed to make.
all install depend clean:
cd ./pm && $(MAKE) $@
cd ./fs && $(MAKE) $@
- cd ./sm && $(MAKE) $@
+ cd ./rs && $(MAKE) $@
cd ./is && $(MAKE) $@
cd ./init && $(MAKE) $@
cd ./inet && $(MAKE) $@
if (pressed(F11)) timing_dmp();
if (pressed(F12)) sched_dmp();
-#if DEAD_CODE
if (pressed(F9)) {
printf("IS server going into infinite loop... hit 5x a function key\n");
printf("Five times a function key is fine as well ...\n");
printf("IS server back to normal ... \n");
return(EDONTREPLY);
}
-#endif
/* Also check Shift F1-F6 keys. */
if (pressed(SF1)) mproc_dmp();
/* Set process details found in the image table. */
rmp = &mproc[ip->proc_nr];
strncpy(rmp->mp_name, ip->proc_name, PROC_NAME_LEN);
- rmp->mp_parent = SM_PROC_NR;
+ rmp->mp_parent = RS_PROC_NR;
rmp->mp_nice = get_nice_value(ip->priority);
if (ip->proc_nr == INIT_PROC_NR) { /* user process */
rmp->mp_pid = INIT_PID;
--- /dev/null
+# Makefile for Reincarnation Server (RS)
+SERVER = rs
+UTIL = service
+
+# directories
+u = /usr
+i = $u/include
+s = $i/sys
+m = $i/minix
+b = $i/ibm
+
+# programs, flags, etc.
+CC = exec cc
+CFLAGS = -I$i
+LDFLAGS = -i
+UTIL_LIBS = -lsys
+LIBS = -lsys -lsysutil
+
+UTIL_OBJ = service.o
+OBJ = rs.o manager.o
+
+# build local binary
+all build: $(SERVER) $(UTIL)
+$(UTIL): $(UTIL_OBJ)
+ $(CC) -o $@ $(LDFLAGS) $(UTIL_OBJ) $(UTIL_LIBS)
+$(SERVER): $(OBJ)
+ $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
+
+# install with other servers
+install: /bin/$(UTIL) /usr/sbin/$(SERVER)
+/bin/$(UTIL): $(UTIL)
+ install -c $? $@
+/usr/sbin/$(SERVER): $(SERVER)
+ install -o root -c $? $@
+
+# clean up local files
+clean:
+ rm -f $(UTIL) $(SERVER) *.o *.bak
+
+depend:
+ /usr/bin/mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend
+
+# Include generated dependencies.
+include .depend
+
* Jul 22, 2005: Created (Jorrit N. Herder)
*/
-#include "sm.h"
+#include "rs.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
return(OK);
}
+
/*===========================================================================*
* do_stop *
*===========================================================================*/
return(OK);
}
+
_PROTOTYPE( int do_start, (message *m));
_PROTOTYPE( int do_stop, (message *m));
+
-/* System Process Manager.
+/* Reincarnation Server. This servers starts new system services and detects
+ * they are exiting. In case of errors, system services can be restarted.
*
* Created:
* Jul 22, 2005 by Jorrit N. Herder
*/
-#include "sm.h"
+#include "rs.h"
/* Set debugging level to 0, 1, or 2 to see no, some, all debug output. */
#define DEBUG_LEVEL 1
result = do_stop(&m_in);
break;
default:
- printf("Warning, SM got unexpected request %d from %d\n",
+ printf("Warning, RS got unexpected request %d from %d\n",
m_in.m_type, m_in.m_source);
result = EINVAL;
}
}
}
+
/*===========================================================================*
* init_server *
*===========================================================================*/
PRIVATE void init_server(void)
{
-/* Initialize the information service. */
+/* Initialize the reincarnation server. */
int i, s;
struct sigaction sa;
sa.sa_handler = SIG_MESS;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
- if (sigaction(SIGCHLD, &sa, NULL)<0) panic("SM","sigaction failed", errno);
- if (sigaction(SIGTERM, &sa, NULL)<0) panic("SM","sigaction failed", errno);
- if (sigaction(SIGABRT, &sa, NULL)<0) panic("SM","sigaction failed", errno);
- if (sigaction(SIGHUP, &sa, NULL)<0) panic("SM","sigaction failed", errno);
+ if (sigaction(SIGCHLD, &sa, NULL)<0) panic("RS","sigaction failed", errno);
+ if (sigaction(SIGTERM, &sa, NULL)<0) panic("RS","sigaction failed", errno);
+ if (sigaction(SIGABRT, &sa, NULL)<0) panic("RS","sigaction failed", errno);
+ if (sigaction(SIGHUP, &sa, NULL)<0) panic("RS","sigaction failed", errno);
}
+
/*===========================================================================*
* get_work *
*===========================================================================*/
int status = 0;
status = receive(ANY, &m_in); /* this blocks until message arrives */
if (OK != status)
- panic("SM","failed to receive message!", status);
+ panic("RS","failed to receive message!", status);
who = m_in.m_source; /* message arrived! set sender */
callnr = m_in.m_type; /* set function call number */
}
+
/*===========================================================================*
* reply *
*===========================================================================*/
m_out.m_type = result; /* build reply message */
send_status = send(who, &m_out); /* send the message */
if (OK != send_status)
- panic("SM", "unable to send reply!", send_status);
+ panic("RS", "unable to send reply!", send_status);
}
+
+
+/* Utility to start or stop system services. Requests are sent to the
+ * reincarnation server that does the actual work.
+ *
+ * Changes:
+ * Jul 22, 2005: Created (Jorrit N. Herder)
+ */
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
+
/* This array defines all known requests. */
PRIVATE char *known_requests[] = {
"up",
exit(EGENERIC);
}
+
/* Parse and verify correctness of arguments. Report problem and exit if an
* error is found. Store needed parameters in global variables.
*/
return(i);
}
+
/* Main program.
*/
PUBLIC int main(int argc, char **argv)
m.SRV_ARGS_ADDR = req_args;
m.SRV_ARGS_LEN = strlen(req_args);
m.SRV_DEV_MAJOR = req_major;
- if (OK != (s=_taskcall(SM_PROC_NR, SRV_UP, &m)))
+ if (OK != (s=_taskcall(RS_PROC_NR, SRV_UP, &m)))
panic(argv[ARG_NAME], "sendrec to manager server failed", s);
result = m.m_type;
break;