OSP labs 
Author Message
 OSP labs

Hi

        I'm having a problem with my queue. Here is my code and after
that i'll explain my problem.

I have declared 2 pcb_node structure
        PCB start;
        PCB *node;
PCB is "typedef struct pcb_node PCB;"

Here is the pcb_node structure:
struct pcb_node {
    int    pcb_id;
    int    size;
    int    creation_time;
    int    last_dispatch;
    int    last_cpuburst;
    int    accumulated_cpu;
    PAGE_TBL *page_tbl;
    STATUS status;
    EVENT  *event;
    int    priority;
    PCB    *next;
    PCB    *prev;
    int    *hook;

Quote:
};

Here is my function which brings me my problem:
void insert_ready(pcb)
PCB *pcb;
{
        FILE *fp = fopen("/dev/tty", "w");

        fprintf(fp, "[insert_ready]: Avant le if\n");
        fprintf(fp, "[insert_ready]: Valeur du pcb=%p\n", pcb);
        fprintf(fp, "[insert_ready]: Valeur du node=%p\n", node);
        fprintf(fp, "[insert_ready]: Valeur du pcb->pcb_id=%d\n",
pcb->pcb_id);
        if (duplicate(pcb) == false) //Looks for a duplication of
process
        {
                fprintf(fp, "[insert_ready]: Dans le if\n");
                node->next = pcb
                node = node->next;
                node->next = NULL;
                node->status = ready;
        }
        fprintf(fp, "[insert_ready]: Sortie du if\n");

        fclose(fp);

Quote:
}                      

And the output is:
[insert_ready]: Avant le if
[insert_ready]: Valeur du pcb=60f6c
[insert_ready]: Valeur du node=802d8
[insert_ready]: Valeur du pcb->pcb_id=0
[duplicate]: Valeur de b_return: 0
[insert_ready]: Dans le if
Segmentation fault

The problem seems to be when I try to assign the value of my
pcb(process control block) to the node of my queue.

I'm using the next value of the pcb structure to do my queue. But when
I do
        node->next = pcb;
I have a segmentation fault.

Can someone help me ?

P.S If you need more part of the code, let me know.
Thanks
Martin



Mon, 10 Mar 2003 03:00:00 GMT  
 OSP labs

Quote:

> Hi

>    I'm having a problem with my queue. Here is my code and after
> that i'll explain my problem.

> I have declared 2 pcb_node structure
>    PCB start;
>    PCB *node;
> PCB is "typedef struct pcb_node PCB;"

> Here is the pcb_node structure:
> struct pcb_node {
>     int    pcb_id;
>     int    size;
>     int    creation_time;
>     int    last_dispatch;
>     int    last_cpuburst;
>     int    accumulated_cpu;
>     PAGE_TBL *page_tbl;
>     STATUS status;
>     EVENT  *event;
>     int    priority;
>     PCB    *next;
>     PCB    *prev;
>     int    *hook;
> };

> Here is my function which brings me my problem:
> void insert_ready(pcb)
> PCB *pcb;
> {
>         FILE *fp = fopen("/dev/tty", "w");

>         fprintf(fp, "[insert_ready]: Avant le if\n");
>         fprintf(fp, "[insert_ready]: Valeur du pcb=%p\n", pcb);
>         fprintf(fp, "[insert_ready]: Valeur du node=%p\n", node);
>         fprintf(fp, "[insert_ready]: Valeur du pcb->pcb_id=%d\n",
> pcb->pcb_id);
>         if (duplicate(pcb) == false) //Looks for a duplication of
> process
>         {
>                 fprintf(fp, "[insert_ready]: Dans le if\n");
>                 node->next = pcb
>                 node = node->next;
>                 node->next = NULL;
>                 node->status = ready;
>         }
>         fprintf(fp, "[insert_ready]: Sortie du if\n");

>         fclose(fp);
> }                      

> And the output is:
> [insert_ready]: Avant le if
> [insert_ready]: Valeur du pcb=60f6c
> [insert_ready]: Valeur du node=802d8
> [insert_ready]: Valeur du pcb->pcb_id=0
> [duplicate]: Valeur de b_return: 0
> [insert_ready]: Dans le if
> Segmentation fault

> The problem seems to be when I try to assign the value of my
> pcb(process control block) to the node of my queue.

> I'm using the next value of the pcb structure to do my queue. But when
> I do
>    node->next = pcb;
> I have a segmentation fault.

Either 'node' does not point to the right place (but since it's non-zero
I'll assume that is does) or 'pcb->next' is not what you think it is,
causing the statement "node->next = NULL;" to access forbidden memory.
Check that 'pcb->next' points to a PCB.

Quote:
> Can someone help me ?

> P.S If you need more part of the code, let me know.
> Thanks
> Martin

--
Jonathan Headland
Wind River
Jakob-Haringer-Str. 8
A-5020 Salzburg, Austria     "function returning void" is oxymoronic


Mon, 10 Mar 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. OSP (Operating System Project) HELP HELP HELP HELP (files module)

2. OSP (Operating System Project) HEEELLPP

3. Anybody ever programmed in OSP with C?

4. labs(LONG_MIN)

5. Suggestions Needed for Lab Windows and CVI

6. Boston Lab Windows / CVI Developer

7. US-NJ-Old Bridge Unix Administrator NCR/Unix Labs TCP/IP networking

8. Learning a language for computer lab manager

9. UMIACS Prallel Processing Lab Invites Usage of its Facilities

10. Global Lab Image API- Visual C++ linking problem

11. Global Lab Image API- Visual C++ linking problem

12. Frustrated Lab Manager

 

 
Powered by phpBB® Forum Software