Saturday, July 16, 2011

What does static void function () means??

what does static void() function means.
it means When you don't want a function to be called from other functions that are defined in other files.

main.c

   main()
   {
     Func1(); //this is not accassble here  since it is static in the funcs.c file

     Func2();//this is accassble here
   }
 

funcs.c

   static void Func1(void); // i am static im not going out side of this class :-)
   void Func2(void);

     
   void Func1(void)
   {
     printf("Func1 called");
   }


   void Func2(void)      
   {
     printf("Func2 called");
   }

Thursday, July 7, 2011

Domain Sockets Vs Shared Memory

Domain Sockets Vs Shared Memory
--------------------------------------------
It's been a question for a long time,which is a better design approach.
Shared Memory ( Shared Memory is faster),
domain sockets(less problems,nearness to real life).

Shared Memory advantages
-----------------------------------
non-linear storage
will never block
multiple programs can access it.

Shared Memory disadvantages
------------------------------------------
need locking implementation
need manual freeing, even if unused by any program
Programs that crash in a critical region
Programs that spend too long time in the critical region
Locking too much
Distributed shared memory
Sharing limits scalability
Sharing can introduce deadlocks
Sharing makes systems error prone and debugging difficult
Sharing doesn't exist in the real world

Domain Sockets advantages
----------------------------------------
blocking and non-blocking mode and switching between them
you don't have to free them when tasks are completed

Domain sockets disadvantages
----------------------------------------
must read and write in a linear fashion

Finally Domain sockets are a lot easier to re-implement a distributed computing. The speed gain factor of Shared Memory will be lost because of the need of a safe design. However, with the use of proper kernel calls in a particular architecture,one can achieve greater speed with Shared Memory.