i need some advice

This is a discussion on i need some advice within the C Programming forums, part of the General Programming Boards category; im making a school project in c programming.. and i need some advice. the program is about an hospital. i ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    29

    i need some advice

    im making a school project in c programming.. and i need some advice.

    the program is about an hospital.

    i have made a struct which holds the information about the patiens infomation such as social sec. nr, injury ect.

    there has to be 2 processors which reseive these patiens, and they can only take on at a time. The rest have to wait in the waiting room

    my quastion is how can do that?

    i was thinking about creating to processors by running fork(), 2 times. and the create a pipe transferring the whole struct. Is this possible and how do i tranfor a whole struct with a pipe?

    my secound quastion is how should i make sure that only the 2 processors only reseive 1 patient at a time. I was thinking about a semifor.. which i could initialize to 2... how can i do that


    pls help.. and keep it as simple as possible.. im new in the field.. thanks

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,500
    > Is this possible and how do i tranfor a whole struct with a pipe?
    Yes, you should be able to write() a block of binary data to the file and read() it again at the other end. But make sure the struct does not contain any pointers, because the pointer won't mean anything when it's read at the other end.

    > my secound quastion is how should i make sure that only the 2 processors only reseive 1 patient at a time
    You send a patient to one of the receiver tasks, and then wait for a "finished" message in response. If you have patients in the waiting room, then send another one.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Advice on C Programming with MSVC++ 2008
    By IT_Guy in forum Windows Programming
    Replies: 1
    Last Post: 03-06-2009, 03:23 AM
  2. girl friend advice (prob. the wrong place)
    By B0bDole in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 10-22-2004, 06:38 PM
  3. need advice on project
    By lambs4 in forum C Programming
    Replies: 2
    Last Post: 07-23-2003, 01:06 PM
  4. need hardware advice....
    By forgottenPWord in forum Tech Board
    Replies: 5
    Last Post: 03-23-2003, 08:12 AM
  5. Newbie: Seek advice
    By gogo in forum C++ Programming
    Replies: 4
    Last Post: 11-06-2001, 09:04 AM

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