Search:

Type: Posts; User: Redsam121

Page 1 of 2 1 2

Search: Search took 0.00 seconds.

  1. Replies
    17
    Views
    7,365

    The code is now going through the input...

    The code is now going through the input successfully, but for some reason this isn't printing


    fprintf(share->out, "Lift-%d Operation\r\n" "Previous position: Floor %d\r\n"
    ...
  2. Replies
    17
    Views
    7,365

    I'm now using virtualbox to test the code shmget...

    I'm now using virtualbox to test the code shmget is now working but shmat is giving permission denied.

    So I changed shmget to const int shared_mem_id = shmget(IPC_PRIVATE, 2 * sizeof(sem_t),...
  3. Replies
    17
    Views
    7,365

    Is there any other option for windows 8

    Is there any other option for windows 8
  4. Replies
    17
    Views
    7,365

    Error reports E1: Function not implemented E2:...

    Error reports
    E1: Function not implemented
    E2: Invalid arguement

    shared_mem_id is printing as -1. I'm using cygwin to test this code since I'm using windows.
  5. Replies
    17
    Views
    7,365

    I'm no longer getting those warnings on...

    I'm no longer getting those warnings on compiling. But the code just suddenly stops at sem_init(full, 1, 1);.


    int shared_mem_id = shmget(IPC_PRIVATE, 2 * sizeof(sem_t), IPC_CREAT);//must...
  6. Replies
    17
    Views
    7,365

    Yes I am getting those errors. However the code...

    Yes I am getting those errors. However the code now stops immediately at sem_init(full, 1, 1);.

    By the way shouldn't full = &sems[0]; be full = &two_sems[0];?
  7. Replies
    17
    Views
    7,365

    I've been running diagnostics on it and I found...

    I've been running diagnostics on it and I found that it doesn't return to lift-R when the buffer is empty and instead goes to lift-2 then lift-3. I'm positive it's to do with the sem mutexs.

    ...
  8. Replies
    17
    Views
    7,365

    When the buffer is full and calls...

    When the buffer is full and calls sem_wait(&full); it goes into an infinite loop. I only want the while(1) to go until the sem_wait is called, then go to lift and return to request_t. It only stops...
  9. Replies
    17
    Views
    7,365

    Okay I've changed the size to (2 * sizeof(sem_t))...

    Okay I've changed the size to (2 * sizeof(sem_t)) which should double the size for two semaphores. I've also changed void main to int main.
  10. Replies
    17
    Views
    7,365

    I've solved the buffer and share problem, but now...

    I've solved the buffer and share problem, but now having problems with the sem mutex. For example in request_t, even when wait is called, it continues in an infinite loop unless I add a break or...
  11. Replies
    17
    Views
    7,365

    Process based circular buffer not working

    I'm converting the program I wrote from the previous thread to use processes instead of threads. Since I got the pthread to work with the help of Salem, I don't need to worry about the looping...
  12. Here is the latest update so far. It now goes...

    Here is the latest update so far. It now goes through the file to the end, but once it's finished it becomes stuck in "Waiting for request" and only uses lift-1. Each lift should be used one at a...
  13. I came up with a solution for...

    I came up with a solution for (fscanf(((share_t*)vargp)->in, "%d %d\n", &A[in].from, &A[in].to) != EOF). I put it into an if statement and when it reaches the file, it'll break the while loop.
  14. I tried using while...

    I tried using while (fscanf(((share_t*)vargp)->in, "%d %d\n", &A[in].from, &A[in].to) != EOF) before but that caused the lift write the wrong values to output. A value would be print before the...
  15. All is forgiven, mistakes happen. So how do I...

    All is forgiven, mistakes happen. So how do I stop the three lift threads from exiting until request thread is done?
  16. But previously you said >Another problem is...

    But previously you said
    >Another problem is both threads are writing to your output file in an unsafe way.

    >request_t has a different mutex to lift.

    So I removed one of the mutexes.

    Also...
  17. My latest update of the code. I've changed the...

    My latest update of the code. I've changed the error checking parameters and added an error check for argc. I've change the fprintfs to singluars, but haven't implemented sprintf. I've also changed...
  18. So for the sprintf, it'd be something like...

    So for the sprintf, it'd be something like sprintf(A[i].line, "New Lift Request from Floor %d to Floor %d \n", A[in_i].from, A[in_i].to); and then fprintf("%s", A[i].line);? Is my assumption correct?...
  19. I solved the in and struct problems, they were...

    I solved the in and struct problems, they were printing properly but the crashing was causing the output file to blank. So they're fine.

    I don't know if I arranged the pthread_join()s correctly...
  20. I temporarily disabled mutex destroy, but the...

    I temporarily disabled mutex destroy, but the program still crashes after lift-3. I want it to return to lift-1 and keep going until the end of the text file.
  21. The main problem is that it crashes after lift-3.

    The main problem is that it crashes after lift-3.
  22. This is what I've got so far: #include...

    This is what I've got so far:



    #include <stdio.h>
    #include <stdlib.h>
    #include <pthread.h>
    #include <unistd.h>
    #include <assert.h>
    #include "list.h"
  23. I've changed mutex to only one lock. Both now...

    I've changed mutex to only one lock. Both now have the same mutex. I'm now getting errors for fscanf on line 71. It's reporting too many arguements.
  24. I implemented it but it caused the entire code...

    I implemented it but it caused the entire code crash on the third lift. Plus I don't think ((share_t*)vargp)->in will work anymore.
  25. But a local pointer can't be shared globally and...

    But a local pointer can't be shared globally and I need that space in pthread_creare for *out so I can print results to output.
    Even if I did create a local pointer like int* id, what am I supposed...
Results 1 to 25 of 29
Page 1 of 2 1 2