Search:

Type: Posts; User: erasm

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Replies
    2
    Views
    5,695

    Access violation reading location

    I can't find anything wrong with my code. When i debug, this occurs.

    Unhandled exception at 0x00fb74b1 in pacman.exe: 0xC0000005: Access violation reading location 0xfdfdfdfd.


    printf("Lowest...
  2. Replies
    8
    Views
    1,270

    The semWait should suspend the producer thread...

    The semWait should suspend the producer thread until it is signaled by
    get_buffer(). My semaphore's purpose is to protect buffer contents from being incorrectly overwritten and stop reading of an...
  3. Replies
    8
    Views
    1,270

    using i instead of random() from put buffer =...

    using i instead of random()

    from put buffer = 0
    from put buffer = 1
    from put buffer = 2
    from put buffer = 3
    from put buffer = 4
    from put buffer = 5
    from put buffer = 6
    from put buffer = 7
  4. Replies
    8
    Views
    1,270

    I am trying to follow this logic for a full...

    I am trying to follow this logic for a full buffer from a c++ tutorial and i can't see how my code is different. :(

    From C++Course: Circular Buffer

    if ((next + 1) % array.length == first)
    ...
  5. Replies
    8
    Views
    1,270

    The buffer should suspend when it is "full" and...

    The buffer should suspend when it is "full" and therefore not being overwritten by the last output block.
  6. Replies
    8
    Views
    1,270

    Lost with wrong output

    I can't see how this code isn't getting the output which should be:

    buffer elem = -378931907
    buffer elem = 1991142473
    buffer elem = -2051466334
    buffer elem = -1945167320
    buffer elem =...
  7. Replies
    1
    Views
    1,387

    Segmentation fault

    Why is this code getting a segmentation fault? how do i fix this?


    void *producer(void* cb)
    {
    printf("testing\n");
    bufferQueue *cbuffer = (bufferQueue *)cb;
    ...
  8. Thread: Compile help

    by erasm
    Replies
    3
    Views
    1,340

    semWait is defined in sema.c and the function...

    semWait is defined in sema.c and the function prototype is in sema.h

    sema.h


    #include <pthread.h>

    typedef struct semaphore
    {
  9. Thread: Compile help

    by erasm
    Replies
    3
    Views
    1,340

    Compile help

    It's me again :)

    When i compile i get this undefined reference to semWait

    I don't know if the problem is with my make file or code.

    Compiler:

    gcc -lpthread -o pctest pctest.o circbuffer.o...
  10. Replies
    2
    Views
    4,592

    Circular buffer - logic difficulty

    I have written a get_buffer function that will not allow the buffer to be read if the buffer is empty. However, i am having difficulty doing the logic for the requirement of disallowing the buffer to...
  11. Replies
    4
    Views
    2,415

    I am using a C++ tutorial as a reference on...

    I am using a C++ tutorial as a reference on circular buffers and have a problem understanding the logic behind part of it.

    Shouldn't remove() return an array excluding the oldest element in the...
  12. Replies
    4
    Views
    2,415

    Should i use max - min to allocate memory for the...

    Should i use max - min to allocate memory for the buffer array?

    If so how would this be implemented, i am having difficulty getting my head around the manual for malloc :(
  13. Replies
    4
    Views
    2,415

    Dynamic array - malloc

    I would like to implement a dynamic array buffer_array for this tutorial. A hint for the tutorial suggests using malloc. How can malloc be used to implement this dynamic array for my tutorial?

    ...
  14. Replies
    30
    Views
    6,183

    Can this be done with only one semaphore...

    Can this be done with only one semaphore initialized?
  15. Replies
    30
    Views
    6,183

    In order to test my semaphore i have used this...

    In order to test my semaphore i have used this implementation

    So far the program will spawn a child which sleeps immediately and the parent reads buffer. Then when the child thread awakes it makes...
  16. Replies
    30
    Views
    6,183

    Now that i have written some semaphore functions...

    Now that i have written some semaphore functions i want to implement this program that used mutexes to achieve safe synchronization with these functions. But i am not sure how to approach this...
  17. Replies
    3
    Views
    15,285

    And the semSignal function: void...

    And the semSignal function:


    void semSignal(semaphore *s)
    {

    pthread_mutex_lock(&(s->request_mutex));

    if (s->count <= 0)
    {
  18. Replies
    3
    Views
    15,285

    Semaphore algorithm

    I am trying to implement the following algorithm as a semaphore. The semaphore struct will be passed as a parameter to semWait and semSigal.

    - Are the mutexes responsible for protecting the...
  19. Replies
    3
    Views
    6,584

    Sorry i omitted some code.

    Sorry i omitted some code.
  20. Replies
    3
    Views
    6,584

    mutex race condition

    I am having difficulty finding the race condition in this code. The tutorial i am doing indicates a semaphore implementation is needed to solve the race condition that cannot be solved by mutexes...
  21. Replies
    30
    Views
    6,183

    You missed a lock on m2 from the child thread. ...

    You missed a lock on m2 from the child thread.

    //Parent
    lock(m1)
    lock(m2)
    create_thread ()
    fgets()
    unlock(m1)
    lock(m2)
    printf()
  22. Replies
    30
    Views
    6,183

    Solved. Swapped these around. ...

    Solved.

    Swapped these around.

    pthread_mutex_lock(&(d->mutex_a ));
    pthread_mutex_lock(&(d->mutex_b ));
  23. Replies
    30
    Views
    6,183

    Why is this not printing the buffer? My...

    Why is this not printing the buffer? My understanding as commented in the code, is that once unlock is called on mutex_a in the parent, the suspended child should immediately begin executing which...
  24. Replies
    30
    Views
    6,183

    Sorry, i made an error in my post earlier, the...

    Sorry, i made an error in my post earlier, the tutorial asks to make the parent prompt the user after printing, not after the child is finished. I was using pthread_join to check this but now i need...
  25. Replies
    30
    Views
    6,183

    Thanks for the reply. Just a few more questions....

    Thanks for the reply. Just a few more questions.

    When you say the thread waits until the mutex is unlocked, do you mean the parent thread is waiting for the child thread to become unlocked?
    ...
Results 1 to 25 of 70
Page 1 of 3 1 2 3