Showing posts with label unix ipc programming. Show all posts
Showing posts with label unix ipc programming. Show all posts

InterProcess Communication Symbian

Inter-Process Communication (IPC) in Symbian
In Symbian for IPC there are majorly three mechanisms.
client–server
publish and subscribe and
message queues,

Now we shall understand the publish and subscribe method of IPC.

The publish and subscribe mechanism was created to provide asynchronous multicast event notification, and to allow for connectionless communication between threads.

Basically publish and subscribe is good for notification of state changes and to subscribe to them

Subscribe – to get the changes the system wide properties.
Impose Platform security by protecting properties against malicious manipulation

Publish and subscribe and platform security

From Symbian OS v9 processes are partitioned so that one process cannot interfere with the property
of another process.

Publish and subscribe provides a means to define and publish changes
to system-wide global variables known as ‘‘properties’’.
Changes to the properties can be ‘published to more than one interested subscriber asynchronously.

Properties are data values “ uniquely identified by a 64-bit integer”.
Properties are the only information that must be shared between a publisher and a subscriber

Once a property has been defined, it will persist in the kernel until it is deleted explicitly or the system reboots. The property’s lifetime is not linked to that of the defining thread or process

A property is published by calling Set()API. This api writes a new value atomically to the property, facilitating the access by multiple threads.

Subscribers do not need to know which component is publishing to a property,
But only identity of the property which is of its interest.

Publishers and subscribers do not need any hard connections.
joining and leaving without any connection is possible in Publish and subscribe.

Before accepting a subscription to a property,
1. The security policy is checked which was defined when the property was created initially
2. The subscription request only completes if the check fails or succeeds.

Conclusion:--
Publish and subscribe IPC mechanism should be used when a component needs
to supply or consume timely and atomic information to or from an unknown number of interested parties, while maintaining loose coupling.
Bluetooth-radio on/off
WiFi - on/off
flight-mode

Explain kill() in unix and its possible return values.

Explain kill() in unix and its possible return values.
There are four possible results from this call:
‘kill()’ returns 0. This implies that a process exists with the given PID, and the system would allow you to
send signals to it. It is system-dependent whether the process could be a zombie.
‘kill()’ returns -1, ‘errno == ESRCH’ either no process exists with the given PID, or security enhancements
are causing the system to deny its existence. (On some systems, the process could be a zombie.)
‘kill()’ returns -1, ‘errno == EPERM’ the system would not allow you to kill the specified process. This means
that either the process exists (again, it could be a zombie) or draconian security enhancements are present
(e.g. your process is not allowed to send signals to *anybody*).
‘kill()’ returns -1, with some other value of ‘errno’ you are in trouble! The most-used technique is to assume
that success or failure with ‘EPERM’ implies that the process exists, and any other error implies that it
doesn't.
An alternative exists, if you are writing specifically for a system (or all those systems) that provide a ‘/proc’
filesystem: checking for the existence of ‘/proc/PID’ may work.

How do you execute one program from within another in unix

How do you execute one program from within another in unix

Question :How do you execute one program from within anotherin unix?
Answer :The system calls used for low-level process creation are execlp() and execvp(). The execlp call overlays the existing program with the new one , runs that and exits. The original program gets back control only when an error occurs. execlp(path,file_name,arguments..); //last argument must be NULL A variant of execlp called execvp is used when the number of arguments is not known in advance. execvp(path,argument_array); //argument array should be terminated by NULL
Keywords:
return value from one shell script to another
how to pass variable from one function to another in shell script
bash function call another function
calling functions in shell script
unix function with argument
bash function run command
write function in unix
factorial program in shell script using function