From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,92673fdb0bb1aef7,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1995-02-05 02:57:51 PST Newsgroups: comp.unix.osf.osf1 From: Andrew@cucumber.demon.co.uk (Andrew Gabriel) Path: nntp.gmd.de!dearn!esoc!linuxed1!peernews.demon.co.uk!cucumber.demon.co.uk!Andrew Cc: Andrew.Gabriel@net-tel.co.uk Subject: makecontext(3) and swapcontext(3) for OSF/1 V2.0 ? Organization: home Reply-To: Andrew@cucumber.demon.co.uk, Andrew.Gabriel@net-tel.co.uk X-Newsreader: Demon Internet Simple News v1.29 X-Posting-Host: cucumber.demon.co.uk Date: Sun, 5 Feb 1995 10:57:51 +0000 Message-ID: <791981871snz@cucumber.demon.co.uk> Sender: usenet@demon.co.uk I am porting an application to DEC Alpha running OSF/1 V2.0, which is new to me. We make use of the internal process context switching functions getcontext(2), makecontext(3), and swapcontext(3). However, OSF/1 seems to be missing makecontext(3) and swapcontext(3). No problem, I thought. The missing ones are only library functions; I'll write them myself... ...famous last words! I have written a plausable swapcontext(3), based on getcontext(2) and setcontext(2). Not actually tried it yet though. However, I cannot get my makecontext(3) to work. I think this takes a ucontext_t structure, and modifies the program counter saved in it, setting it to the address of a function passed as an argument. (It also allows arguments to be passed to the function, but I've ignored this since in my case, I never pass any.) However, this does not seem to be working. When I call setcontext(2), it seems to resume from where getcontext(2) was last called, rather than the function address passed to a more recent call on my makecontext(3). This implies to me that I am not saving the function address in the right place. I have tried saving it in sc_pc and in sc_regs[30] (or sc_regs[26], whichever one isn't the stack pointer - this is from memory since listings are at work and I'm currently at home, I might also have names slightly wrong). Can anyone help me out? I found the program counter by repeatedly calling getcontext(2) (not in a loop) and seeing which register in sc_regs[] incremented appropriately between each call (none of the others changed). But there are two other locations in u_context which, judging from their names, might also be program counters? As an added complication, each of my contexts runs with its own stack. So I also need to know where the stack pointer should be saved in the u_context structure (again, there's more than one possible location). Thanks, -- Andrew Gabriel Home: Andrew@cucumber.demon.co.uk Consultant Software Engineer Work: Andrew.Gabriel@net-tel.co.uk