Thread: Project Deadlock Location

  1. #1
    Registered User
    Join Date
    Nov 2022
    Posts
    1

    Project Deadlock Location

    I have a project using multiple threads and semaphores.
    There are 4 threads using the same function as an entry point (Hunters), 1 with its own entry function (Ghost).

    I am running into a problem with the Hunter Threads where it seems like there is a deadlock. I have tried debugging this and I believe the issue is coming from the hunters moving rooms, Potentially the fact that all hunters begin in the same room.

    All Hunters begin in the same room, and can edit any aspect of a room one at a time.

    Source Code Can Be Found On GitHub Here: GitHub - GrewalCreator/GhostHunters: Clean-up of a school assignment to improve the program

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    This syntax (in ghost.c) probably doesn't do what you think:
    Code:
                if(4.70 <= data <= 5.00){
    You probably mean this:
    Code:
                if (4.70 <= data && data <= 5.00) {
    This list handling code is incorrect:
    Code:
    void removeEvidenceNode(EvidenceLinkedList* list, EvidenceNodeType* node){
        if(node != NULL){
            EvidenceNodeType* prev = node->prev;
            EvidenceNodeType* next = node->next;
     
            if(prev == NULL)
                list->head = node->next;
     
            if(next == NULL)
                list->tail = node->prev;
     
            if(next != NULL && prev != NULL) {
                prev->next = next;
                next->prev = prev;
            }
        }
    }
    It should be more like this:
    Code:
    void removeEvidenceNode(EvidenceLinkedList* list, EvidenceNodeType* node){
        if(node != NULL){
            EvidenceNodeType* prev = node->prev;
            EvidenceNodeType* next = node->next;
     
            if(prev == NULL)
                list->head = next;
            else
                prev->next = next;
     
            if(next == NULL)
                list->tail = prev;
            else
                next->prev = prev;
        }
    }
    A little inaccuracy saves tons of explanation. - H.H. Munro

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 05-02-2016, 08:47 PM
  2. producer consumer deadlock
    By strider1974 in forum C Programming
    Replies: 11
    Last Post: 08-17-2009, 10:47 AM
  3. Deadlock prevention in C
    By simpatico_qa in forum C Programming
    Replies: 12
    Last Post: 05-04-2009, 12:35 PM
  4. Can i get a deadlock?
    By johny145 in forum Windows Programming
    Replies: 2
    Last Post: 09-18-2005, 06:43 PM
  5. Deadlock
    By Claudigirl in forum C Programming
    Replies: 2
    Last Post: 11-06-2003, 03:11 PM

Tags for this Thread