How can I make several processes communicate in C?

Programming, for all ages and all languages.
Post Reply
wilsonsamm
Posts: 8
Joined: Mon Mar 24, 2008 6:58 pm

How can I make several processes communicate in C?

Post by wilsonsamm »

I am working on a CPU emulator which on certain preset breakpoints passes some parameters to an OS compatibility layer (like a Wine kind of thing). What this is mean to acheive is that a CP/M program may run in a linux environment, accessing files in the filesystem of the host machine, writing to the terminal of the host computer, and accessing other hardware (actual hardware on the host computer, or emulated) whilst the machine code of the application software itself runs on the emulated CPU.

Both the CPU engine and the OS compatibilty layer are to be written in C.

My problem is this: although I understand the logic behind the problem I'm trying to solve, and could implement it in PDP-8 assembler (if only the PDP-8 were powerful enough! :P ), I'm still only learning C and don't know about how to do some things integral to this idea's working.
:arrow: How can I pass a semaphore to another process?
:arrow: How can several processes have variables and so on in common? When the CPU engine calls the OS compatibility layer for a particular syscall, the OS compat layer will need to look at CPU registers and memory locations for parameters and so on.
:arrow: How do put proper bullet points into this message?
I take my tea with milk
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Re: How can I make several processes communicate in C?

Post by DeletedAccount »

you are asking a very general question that , one could fill pages of answer . Can you be more specific ?




Regards
Shrek
Last edited by DeletedAccount on Sat Jan 10, 2009 10:17 pm, edited 1 time in total.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: How can I make several processes communicate in C?

Post by Love4Boobies »

wilsonsamm wrote: :arrow: How can I pass a semaphore to another process?
Why would you? If you really need to, use IPC (see the next answer).
:arrow: How can several processes have variables and so on in common? When the CPU engine calls the OS compatibility layer for a particular syscall, the OS compat layer will need to look at CPU registers and memory locations for parameters and so on.
Well, by using IPC. The most common two approaches are message passing and shared pages. I'd suggest shared paged for stuff like common variables. Just be careful about those race conditions :wink: Also, you might want to read on transactional memory.
:arrow: How do put proper bullet points into this message?
Use [ list ] [asterisk] foo [asterisk] bar [ /list ]
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
DeletedAccount
Member
Member
Posts: 566
Joined: Tue Jun 20, 2006 9:17 am

Re: How can I make several processes communicate in C?

Post by DeletedAccount »

The most common two approaches are message passing and shared pages
pipes , message queues.... , even by using sockets on loopback ... So i would prefer a more specific query . Also mention the operating system under consideration


Regards
Shrek
Post Reply