Thread: Write a program to copy a file to a destination file using message queues.?

  1. #1
    Registered User
    Join Date
    Jun 2009
    Location
    Bangalore,India
    Posts
    29

    Lightbulb Write a program to copy a file to a destination file using message queues.?

    Write a program to copy a file to a destination file using message queues.
    The server (writer process) has to split the data in the file appropriately
    and send it to the message queue. There should be one writer process which
    writes into the message queue and four reader processes which read the
    appropriate message from message queue and writes into the destination file.
    Use semaphores to synchronize writing into the file by the reader process.

    How to handle this problem?
    If we use 4 reader process and write into one destination file.... with the same copy of source file?
    Last edited by krishnampkkm; 03-03-2010 at 03:02 AM.

  2. #2
    Registered User ungalnanban's Avatar
    Join Date
    Feb 2010
    Location
    Chenai
    Posts
    12

    Thumbs up

    Here is the algorithm ,

    1 . Create a message queue id by using the "msgget".

    2 . Then open the source file and copy a line to the message queue buffer then send that to the queue.

    3 . Among the four process any one has to lock the file by using the semophore functions.

    4. And then the process has the read the queue.And it has to write the current contents of the message queue.

    5.After some times it has to release the lock and increment the semaphore value to 1.
    6. Using the loop just read every line and the same operations.

    First Understand the functions :

    msgget
    msgsnd
    msgctl
    msgrcv
    semget
    semop

  3. #3
    Registered User
    Join Date
    Jun 2009
    Location
    Bangalore,India
    Posts
    29

    Exclamation :):):)



    Tanku

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. Totally confused on assigment using linked lists
    By Uchihanokonoha in forum C++ Programming
    Replies: 8
    Last Post: 01-05-2008, 04:49 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Can I write & read file in same program?
    By chad03 in forum C Programming
    Replies: 2
    Last Post: 08-04-2003, 08:39 AM

Tags for this Thread