hello,

A small doubt regarding the context related functions..

I did a makecontext to create a new thread. ( C program)
But in order to execute it,I need to know the main parent thread so that I can swap both.

How do i know the parent thread..?

i want to use swapcontext(<----> , &child thread);

what do i fill in here in order to swap context with parent thread ?

Recommended Answers

All 3 Replies

What operating system? Is it something that you are writing ? I did something similar in MS-DOS 6.X (a program with multiple context threads). In that program I had a kernel function (kernel to my program) that pushed all registers onto the stack, switch stacks, then poped registers of the new thread. This did not require any context id's

I have no clue what your swapcontext function does, other than swap out one thread for another.

I am using GNU C Library on UNIX platform.
I am trying to create a child thread(makecontext) and swap it with the parent thread.

why? The operating system does all the thread swaping for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.