/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
* required lib is kernel32.lib, header is winbase.h
*/
+#include <afsconfig.h>
#include <afs/param.h>
+
+#include <roken.h>
+
#ifdef AFS_NT40_ENV
-#include <stdio.h>
-#include <stdlib.h>
+#include <afs/opr.h>
#include <afs/afsutil.h>
#include "lwp.h"
#ifdef DEBUG
#define Debug(level, msg)\
if (lwp_debug && lwp_debug >= level) {\
- printf("***LWP (0x%x): ", lwp_cpptr);\
+ printf("***LWP (0x%p): ", lwp_cpptr);\
printf msg;\
putchar('\n');\
}
/* Forward declarations */
static void Dispatcher(void);
-static void Exit_LWP(void);
static void Abort_LWP(char *msg);
static VOID WINAPI Enter_LWP(PVOID fiberData);
static void Initialize_PCB(PROCESS pcb, int priority, int stacksize,
/* Iterator macro */
#define for_all_elts(var, q, body)\
{\
- register PROCESS var, _NEXT_;\
- register int _I_;\
+ PROCESS var, _NEXT_;\
+ int _I_;\
for (_I_=q.count, var = q.head; _I_>0; _I_--, var=_NEXT_) {\
_NEXT_ = var -> next;\
body\
}\
}
+#ifdef AFS_WIN95_ENV
+
+LPVOID ConvertThreadToFiber(PROCESS x)
+{
+ return NULL;
+}
+LPVOID CreateFiber(DWORD x ,LPVOID y,PROCESS z)
+{
+ return NULL;
+}
+
+VOID SwitchToFiber(LPVOID p)
+{
+}
+
+VOID DeleteFiber(LPVOID p)
+{
+}
+#endif
+
int lwp_MinStackSize = 0;
+
/* LWP_InitializeProcessSupport - setup base support for fibers.
*
* Arguments:
* pid - return this process
* value:
* LWP_SUCCESS (else aborts)
- *
+ *
*/
+
int LWP_InitializeProcessSupport(int priority, PROCESS *pid)
{
PROCESS pcb;
- register int i;
+ int i;
char* value;
Debug(0, ("Entered LWP_InitializeProcessSupport"))
Abort_LWP("Insufficient Storage to Initialize LWP PCB");
(void) memset((void*)pcb, 0, sizeof(*pcb));
pcb->fiber = ConvertThreadToFiber(pcb);
- if (pcb == NULL)
+ if (pcb == NULL)
Abort_LWP("Cannot convert main thread to LWP fiber");
lwp_init = (struct lwp_ctl *) malloc(sizeof(struct lwp_ctl));
Initialize_PCB(pcb, priority, 0, NULL, NULL,
- "Main Process [created by LWP]");
+ "Main Process [created by LWP]");
lwp_cpptr = pcb;
- Debug(10, ("Init: Insert 0x%x into runnable at priority %d\n", pcb, priority))
+ Debug(10, ("Init: Insert 0x%p into runnable at priority %d\n", pcb, priority))
insert(pcb, &runnable[priority]);
if ( ( value = getenv("AFS_LWP_STACK_SIZE")) == NULL )
- lwp_MinStackSize = AFS_LWP_MINSTACKSIZE;
+ lwp_MinStackSize = AFS_LWP_MINSTACKSIZE;
else
lwp_MinStackSize = (AFS_LWP_MINSTACKSIZE>atoi(value)?
AFS_LWP_MINSTACKSIZE : atoi(value));
-
+
*pid = pcb;
return LWP_SUCCESS;
*
* Arguments:
* funP - start function
- * stacksize - size of
+ * stacksize - size of
* priority - LWP priority
* argP - initial parameter for start function
* name - name of LWP
char *name, PROCESS *pid)
{
PROCESS pcb;
-
+
purge_dead_pcbs();
pcb = (PROCESS)malloc(sizeof(*pcb));
pcb->fiber = CreateFiber(stacksize, Enter_LWP, pcb);
if (pcb->fiber == NULL) {
- free((void*)pcb);
+ free(pcb);
return LWP_EINIT;
}
- Debug(0, ("Create: pcb=0x%x, funP=0x%x, argP=0x%x\n", pcb, funP, argP))
+ Debug(0, ("Create: pcb=0x%p, funP=0x%p, argP=0x%p\n", pcb, funP, argP))
/* Fiber is now created, so fill in PCB */
Initialize_PCB(pcb, priority, stacksize, funP, argP, name);
- Debug(10, ("Create: Insert 0x%x into runnable at priority %d\n", pcb, priority))
+ Debug(10, ("Create: Insert 0x%p into runnable at priority %d\n", pcb, priority))
insert(pcb, &runnable[priority]);
LWPANCHOR.processcnt++;
if (!lwp_init)
return LWP_EINIT;
-
+
if (lwp_cpptr != pid) {
Dispose_of_Dead_PCB(pid);
} else {
{
if (pid->status == QWAITING) {
pid->status = READY;
- Debug(10, ("QSignal: Insert 0x%x into runnable at priority %d\n", pid, pid->priority))
+ Debug(10, ("QSignal: Insert 0x%p into runnable at priority %d\n", pid, pid->priority))
insert(pid, &runnable[pid->priority]);
return LWP_SUCCESS;
}
static void Dump_Processes(void)
{
if (lwp_init) {
- register int i;
+ int i;
for (i=0; i<MAX_PRIORITIES; i++)
for_all_elts(x, runnable[i], {
printf("[Priority %d]\n", i);
int rc = LWP_ENOWAIT;
int i;
- Debug(0, ("Entered Internal_Signal [event id 0x%x]", event))
+ Debug(0, ("Entered Internal_Signal [event id 0x%p]", event))
if (!lwp_init) return LWP_EINIT;
if (event == NULL) return LWP_EBADEVENT;
for_all_elts(temp, blocked, {
if (temp -> eventlist[i] == event) {
temp -> eventlist[i] = NULL;
rc = LWP_SUCCESS;
- Debug(0, ("Signal satisfied for PCB 0x%x", temp))
+ Debug(0, ("Signal satisfied for PCB 0x%p", temp))
if (--temp->waitcnt == 0) {
temp -> status = READY;
temp -> wakevent = i+1;
int LWP_TerminateProcessSupport() /* terminate all LWP support */
{
- register int i;
+ int i;
Debug(0, ("Entered Terminate_Process_Support"))
if (lwp_init == NULL) return LWP_EINIT;
if (ecount > lwp_cpptr->eventlistsize) {
void **save_eventlist = lwp_cpptr->eventlist;
- lwp_cpptr->eventlist = (char **)realloc(lwp_cpptr->eventlist,
- ecount*sizeof(char *));
+ lwp_cpptr->eventlist = realloc(lwp_cpptr->eventlist,
+ ecount*sizeof(char *));
if (lwp_cpptr->eventlist == NULL) {
lwp_cpptr->eventlist = save_eventlist;
Dispatcher();
}
-VOID WINAPI Enter_LWP(PVOID fiberData)
+static VOID WINAPI Enter_LWP(PVOID fiberData)
{
PROCESS pcb = (PROCESS)fiberData;
/* next lines are new..... */
lwp_cpptr = pcb;
- Debug(2, ("Enter_LWP: pcb=0x%x, funP=0x%x, argP=0x%x\n", pcb, pcb->funP, pcb->argP))
+ Debug(2, ("Enter_LWP: pcb=0x%p, funP=0x%p, argP=0x%p\n", pcb, pcb->funP, pcb->argP))
(*pcb->funP)(pcb->argP);
printf("***LWP: Abort --- dumping PCBs ...\n");
Dump_Processes();
#endif
- Exit_LWP();
+ opr_abort();
}
#ifdef DEBUG
{
int i;
- printf("***LWP: Process Control Block at 0x%x\n", pid);
+ printf("***LWP: Process Control Block at 0x%p\n", pid);
printf("***LWP: Name: %s\n", pid->name);
if (pid->funP != NULL)
- printf("***LWP: Initial entry point: 0x%x\n", pid->funP);
+ printf("***LWP: Initial entry point: 0x%p\n", pid->funP);
switch (pid->status) {
case READY: printf("READY"); break;
case WAITING: printf("WAITING"); break;
default: printf("unknown");
}
putchar('\n');
- printf("***LWP: Priority: %d \tInitial parameter: 0x%x\n",
+ printf("***LWP: Priority: %d \tInitial parameter: 0x%p\n",
pid->priority, pid->argP);
if (pid->stacksize != 0) {
printf("***LWP: Stacksize: %d\n", pid->stacksize);
printf("***LWP: Number of events outstanding: %d\n", pid->waitcnt);
printf("***LWP: Event id list:");
for (i=0;i<pid->eventcnt;i++)
- printf(" 0x%x", pid->eventlist[i]);
+ printf(" 0x%p", pid->eventlist[i]);
putchar('\n');
}
if (pid->wakevent>0)
static void Dispatcher(void)
{
- register int i;
+ int i;
#ifdef DEBUG
static int dispatch_count = 0;
#ifdef DEBUG
if (LWP_TraceProcesses > 0)
- printf("Dispatch %d [PCB at 0x%x] \"%s\"\n", ++dispatch_count,
+ printf("Dispatch %d [PCB at 0x%p] \"%s\"\n", ++dispatch_count,
runnable[i].head, runnable[i].head->name);
#endif
SwitchToFiber(lwp_cpptr->fiber);
}
-void lwp_abort(void)
-{
- afs_NTAbort();
-}
-
-static void Exit_LWP(void)
-{
-
- lwp_abort();
-}
-
static void Delete_PCB(PROCESS pid)
{
Debug(4, ("Entered Delete_PCB"))
LWPANCHOR.processcnt--;
}
+
static void Free_PCB(PROCESS pid)
{
Debug(4, ("Entered Free_PCB"))
if (pid->fiber != NULL) {
DeleteFiber(pid->fiber);
}
- if (pid->eventlist != NULL) free((void*)pid->eventlist);
- free((void*)pid);
+ if (pid->eventlist != NULL) free(pid->eventlist);
+ free(pid);
}
static void Dispose_of_Dead_PCB(PROCESS cur)