summaryrefslogtreecommitdiff
path: root/emu/Nt/os.c
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-23 00:30:12 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-23 00:30:12 +0000
commit6e425a9de8c003b5a733621a6b6730ec3cc902b8 (patch)
tree314123bcab78ff295f38f85f31dc141e5fe22d15 /emu/Nt/os.c
parent74a4d8c26dd3c1e9febcb717cfd6cb6512991a7a (diff)
20061220
Diffstat (limited to 'emu/Nt/os.c')
-rw-r--r--emu/Nt/os.c105
1 files changed, 15 insertions, 90 deletions
diff --git a/emu/Nt/os.c b/emu/Nt/os.c
index 023d47c3..3f7156d9 100644
--- a/emu/Nt/os.c
+++ b/emu/Nt/os.c
@@ -64,24 +64,24 @@ pfree(Proc *p)
}
free(e->user);
free(p->prog);
+ CloseHandle((HANDLE)p->os);
free(p);
}
-static ulong erendezvous(void*, ulong);
-
void
osblock(void)
{
- erendezvous(up, 0);
+ if(WaitForSingleObject((HANDLE)up->os, INFINITE) != WAIT_OBJECT_0)
+ panic("osblock failed");
}
void
osready(Proc *p)
{
- erendezvous(p, 0);
+ if(SetEvent((HANDLE)p->os) == FALSE)
+ panic("osready failed");
}
-
void
pexit(char *msg, int t)
{
@@ -118,11 +118,9 @@ tramp(LPVOID p)
up = p;
up->func(up->arg);
pexit("", 0);
- // should never get here but tidy up anyway
- _asm {
- mov fs:[0],-1
- add esp, 8
- }
+ /* not reached */
+ for(;;)
+ panic("tramp");
return 0;
}
@@ -140,6 +138,12 @@ kproc(char *name, void (*func)(void*), void *arg, int flags)
print("out of kernel processes\n");
return -1;
}
+ p->os = CreateEvent(NULL, FALSE, FALSE, NULL);
+ if(p->os == NULL){
+ pfree(p);
+ print("can't allocate os event\n");
+ return -1;
+ }
if(flags & KPDUPPG) {
pg = up->env->pgrp;
@@ -429,7 +433,7 @@ libinit(char *imod)
lasterror = GetLastError();
if(PlatformId == VER_PLATFORM_WIN32_NT || lasterror != ERROR_NOT_LOGGED_ON)
print("cannot GetUserName: %d\n", lasterror);
- } else {
+ }else{
uns = narrowen(wuname);
snprint(uname, sizeof(uname), "%s", uns);
free(uns);
@@ -439,85 +443,6 @@ libinit(char *imod)
emuinit(imod);
}
-enum
-{
- NHLOG = 7,
- NHASH = (1<<NHLOG)
-};
-
-typedef struct Tag Tag;
-struct Tag
-{
- void* tag;
- ulong val;
- HANDLE pid;
- Tag* next;
-};
-
-static Tag* ht[NHASH];
-static Tag* ft;
-static Lock hlock;
-static int nsema;
-
-static ulong
-erendezvous(void *tag, ulong value)
-{
- int h;
- ulong rval;
- Tag *t, **l, *f;
-
-
- h = (ulong)tag & (NHASH-1);
-
- lock(&hlock);
- l = &ht[h];
- for(t = ht[h]; t; t = t->next) {
- if(t->tag == tag) {
- rval = t->val;
- t->val = value;
- t->tag = 0;
- unlock(&hlock);
- if(SetEvent(t->pid) == FALSE)
- panic("Release failed\n");
- return rval;
- }
- }
-
- t = ft;
- if(t == 0) {
- t = malloc(sizeof(Tag));
- if(t == nil)
- panic("rendezvous: no memory");
- t->pid = CreateEvent(0, 0, 0, 0);
- }
- else
- ft = t->next;
-
- t->tag = tag;
- t->val = value;
- t->next = *l;
- *l = t;
- unlock(&hlock);
-
- if(WaitForSingleObject(t->pid, INFINITE) != WAIT_OBJECT_0)
- panic("WaitForSingleObject failed\n");
-
- lock(&hlock);
- rval = t->val;
- for(f = *l; f; f = f->next) {
- if(f == t) {
- *l = f->next;
- break;
- }
- l = &f->next;
- }
- t->next = ft;
- ft = t;
- unlock(&hlock);
-
- return rval;
-}
-
void
FPsave(void *fptr)
{