code problem

This is a discussion on code problem within the C Programming forums, part of the General Programming Boards category; Hi, i have a little problem in my code . Code: void thread_exit() { thread_t running_thread = list->element; thread_t next_thread ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    17

    code problem

    Hi, i have a little problem in my code .

    Code:
        void thread_exit() {
        thread_t running_thread = list->element;
        thread_t next_thread = list->next->element;
        remove_list(&list, running_thread);
        thread_switch(running_thread->context, next_thread->context);
        }
    This function terminate a thread that is running, removing her from the list, and
    after removing her, switch the execution context of the thread with the next thread on the list. The problem is that i have to free the structure(running_thread) and her context, but i cant do it before the thread_switch(), neither immediately after, so how can i resolve this problem.

  2. #2
    Logic Junkie
    Join Date
    Nov 2005
    Posts
    31
    Why can't you remove it after thread_switch()?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code problem
    By sybariticak47 in forum C++ Programming
    Replies: 9
    Last Post: 02-28-2006, 10:50 AM
  2. Problem with game code.
    By ajdspud in forum C++ Programming
    Replies: 5
    Last Post: 02-14-2006, 05:39 PM
  3. problem with selection code
    By DavidP in forum Game Programming
    Replies: 1
    Last Post: 06-14-2004, 01:05 PM
  4. Replies: 5
    Last Post: 12-03-2003, 04:47 PM
  5. Help with code for simple Y2K problem
    By Mule in forum C++ Programming
    Replies: 3
    Last Post: 03-05-2003, 11:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21