Shared memory implementation using thread

This is a discussion on Shared memory implementation using thread within the C Programming forums, part of the General Programming Boards category; Hi I am looking for C program source code. Could you please help me in finding the source code required ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    14

    Shared memory implementation using thread

    Hi

    I am looking for C program source code. Could you please help me in finding the source code required mentioned below.


    Task that I need to complete:

    Write a program to create multiple threads (one master thread and rest worker threads) and using the threads write into and read from shared memory

    Restrictions:

    Only one thread should be able to read at any instant of time into shared memory region.

    Only one thread should be able to write at any instant of time into shared memory region.

    Worker threads should inform the master thread after every read and write operation.

    Master thread inform the worker thread (which is waiting to acquire shared memory region) that read or write operation is successful and it can acquire the memory for either reading and writing operations.


    Please send me the code for the same

  2. #2
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    Do your own homework.

  3. #3
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Of course we won't sent you the whole code for obvious reasons. But we can give you some clues. First of all, it is for Windows or Linux?

    If you really find it difficult at least give us some psedo-code and we can help with the specific functions and/or details.

  4. #4
    Registered User
    Join Date
    Jun 2008
    Posts
    14
    It's for AIX and I am new to this OS. Though I have written two separate functions but unable to compile it. I have created an structure and two threads one for reading and another for writing. But nothing seems to be working fine for me.

  5. #5
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    post your code and somebody will probably find the problem

  6. #6
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by kumars View Post
    but unable to compile it.
    Well, posting the code and the compiler errors would be a start...

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problems with shared memory shmdt() shmctl()
    By Jcarroll in forum C Programming
    Replies: 1
    Last Post: 03-17-2009, 10:48 PM
  2. Problem with linked list and shared memory
    By Sirfabius in forum C Programming
    Replies: 10
    Last Post: 11-10-2008, 03:45 PM
  3. thread and shared memory manipulation
    By taher84 in forum C Programming
    Replies: 4
    Last Post: 07-25-2006, 04:05 AM
  4. Shared Memory - shmget questions
    By hendler in forum C Programming
    Replies: 1
    Last Post: 11-29-2005, 01:15 AM
  5. Win32 Thread Object Model Revisted
    By Codeplug in forum Windows Programming
    Replies: 5
    Last Post: 12-15-2004, 07:50 AM

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