Re: Semaphores in multiprocessor systems.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 15, 2003 at 03:08:16PM +0200, Magnus Myrefors wrote:
> I wonder if it is considered to be a multiprocessor-system in linux if
> you install linux on two pc's and connect them with ethernet or a bus
> ?

No, it's called a cluster. In a wider sense it is a multiprocessor
system, but I suppose you wanted to say "SMP system", which it is not.

SMP (Symetric MultiProcessing) system is a system, that contains several
processors connected to a common bus and sharing a single memory unit.

Note: You _can't_ connect two computers with a local bus.

> If it is, how do you synchronize access to a memoryunit also connected
> with the two pc's with semaphores?

They don't have a common memory unit. Only way processes can communicate
is by sending each other network packets.

> Does this type of programming lie within linux?

No, Linux is not a distributed system.

> If it isn't I suppose you could solve it something
> like this:

>    I guess you cannot have the code for the semaphore compiled on the
>    memoryunit since the two pc's may have different
>    hardware-structures. So, instead I believe you can have
>    a memoryaddress on the memoryunit to protect some codearea. The
>    address initially set to 1 and decreased when one pc wants to
>    access the codearea and set back to 1 when finished.

Not that I really know what you wan't to do, but I really fear it won't
work for the case you want.

This will work for *LOCAL* lock implementation:
- You have a shared variable initialized to 1.
- Process wanting to lock does:
    1 Atomic dec
    2 Check if it's zero
    3 If it is zero: locked ok.
    4 Else atomic inc and goto 1.
- Unlocking is just atomic inc.
Problem is with the "atomic" - you can't get that on distributed system.

So for a distributed system you need some distributed locking mechanizm.
There is one implemented in any library for distributed computations.
Probably best such library is LAM/MPI.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux