@nitish
I think using fork() it is not possible , to achieve , what you are
trying to do ..
Because , though address space is shared , but all the variable of
parent process can't be communicated through child process.as they
dont have a shared memory block.where we can place our semaphore.
It
Please help me in this question.
What's the condition so that the following code prints both HelloWorld !
if condition
printf (Hello);
else
printf(World);
--
-Arpit Mittal
6th Semester,
Indian Institute of Information Technology,Allahabad
Email :
if (!printf(Hello)
printf(Hello);
else
printf(World);
On Fri, Jun 3, 2011 at 11:52 AM, Arpit Mittal mrmittalro...@gmail.comwrote:
Please help me in this question.
What's the condition so that the following code prints both HelloWorld !
if condition
printf (Hello);
else
(!printf(Hello))
On Jun 3, 2011 11:52 AM, Arpit Mittal mrmittalro...@gmail.com wrote:
Please help me in this question.
What's the condition so that the following code prints both HelloWorld !
if condition
printf (Hello);
else
printf(World);
--
-Arpit Mittal
6th Semester,
Indian
can use fork() also..
On Fri, Jun 3, 2011 at 11:57 AM, anand karthik
anandkarthik@gmail.com wrote:
(!printf(Hello))
On Jun 3, 2011 11:52 AM, Arpit Mittal mrmittalro...@gmail.com wrote:
Please help me in this question.
What's the condition so that the following code prints both
Hi Vishal,
Can you show us how it be done with fork?
On Fri, Jun 3, 2011 at 12:02 PM, Vishal Thanki vishaltha...@gmail.comwrote:
can use fork() also..
On Fri, Jun 3, 2011 at 11:57 AM, anand karthik
anandkarthik@gmail.com wrote:
(!printf(Hello))
On Jun 3, 2011 11:52 AM, Arpit
vishal@ubuntu:~/progs/c\ 12:11:53 PM $ cat fork.c
#include stdio.h
#include stdlib.h
int main()
{
if (fork()) {
printf(hello );
} else {
printf(world\n);
}
return 0;
}
vishal@ubuntu:~/progs/c\ 12:11:56 PM $ gcc fork.c
oh yes,
gud one
On Fri, Jun 3, 2011 at 12:12 PM, Vishal Thanki vishaltha...@gmail.comwrote:
vishal@ubuntu:~/progs/c\ 12:11:53 PM $ cat fork.c
#include stdio.h
#include stdlib.h
int main()
{
if (fork()) {
printf(hello );
} else {
but we can't be sure that it will print hello world or world hello :P
On Fri, Jun 3, 2011 at 12:14 PM, Naveen Kumar naveenkumarve...@gmail.comwrote:
oh yes,
gud one
On Fri, Jun 3, 2011 at 12:12 PM, Vishal Thanki vishaltha...@gmail.comwrote:
vishal@ubuntu:~/progs/c\ 12:11:53 PM $ cat
There can be some synchronisation problems with fork() right? say world
might get printed first...or maybe the letters can get jumbled too...We
cannot guarantee the order of execution unless we use semaphores.
On Fri, Jun 3, 2011 at 12:14 PM, Naveen Kumar naveenkumarve...@gmail.comwrote:
oh
@vishal:
can u explain the fork() solution??
On Fri, Jun 3, 2011 at 12:16 PM, Shachindra A C sachindr...@gmail.comwrote:
There can be some synchronisation problems with fork() right? say world
might get printed first...or maybe the letters can get jumbled too...We
cannot guarantee the order
@sachindra, @naveen,
this was just a plain trick to execute if and else block. i agree
with your concerns :)
2011/6/3 Vιиodh vinodh...@gmail.com:
@vishal:
can u explain the fork() solution??
On Fri, Jun 3, 2011 at 12:16 PM, Shachindra A C sachindr...@gmail.com
wrote:
There can be some
Hi Shachindra,
I don't think letters will be jumbled because we a calling one api to output
on console tty's driver takes whole line and output it at once.
On Fri, Jun 3, 2011 at 12:40 PM, Vishal Thanki vishaltha...@gmail.comwrote:
@sachindra, @naveen,
this was just a plain trick to execute
Here you go in C code
http://codepad.org/gk6AZj0T
int main()
{
if(printf(hello)!=0) {
printf(world);
}
else {
printf(SCREWED ! ! !); }
return 0;
}
*
*
*
*
*Subhransu Panigrahi
*
*Mobile:* *+91-9840931538*
*Email:* subhransu.panigr...@gmail.com
On Fri, Jun 3, 2011 at 1:57 PM,
Hi all,
I am stuck with this code..Can anyone tell me how to implement semaphores in
fork system call
Code:
#includestdio.h
int signal(int *n);
int wait(int *n);
int main()
{
int n;
n=0;
if(fork())
{
printf(Hello);
signal(n);
}
else
{
@vishal
plz help me in understanding fork function...how it is working.??
On Fri, Jun 3, 2011 at 9:58 AM, nitish goyal nitishgoy...@gmail.com wrote:
Hi all,
I am stuck with this code..Can anyone tell me how to implement semaphores
in fork system call
Code:
#includestdio.h
int signal(int
While using fork(), child shares parent address space ,
Correct me If I am wrong ..
On Fri, Jun 3, 2011 at 10:28 PM, nitish goyal nitishgoy...@gmail.com wrote:
Hi all,
I am stuck with this code..Can anyone tell me how to implement semaphores in
fork system call
Code:
#includestdio.h
int
@ Lalit
You are right.
that's why i am saying how i can use semaphores in the above example
On Fri, Jun 3, 2011 at 10:37 PM, LALIT SHARMA lks.ru...@gmail.com wrote:
While using fork(), child shares parent address space ,
Correct me If I am wrong ..
On Fri, Jun 3, 2011 at 10:28 PM, nitish
Process don't share address space when forked.
On Fri, Jun 3, 2011 at 10:40 PM, nitish goyal nitishgoy...@gmail.comwrote:
@ Lalit
You are right.
that's why i am saying how i can use semaphores in the above example
On Fri, Jun 3, 2011 at 10:37 PM, LALIT SHARMA lks.ru...@gmail.com wrote:
i mean why both the if else statements are working by using fork ?
On Fri, Jun 3, 2011 at 10:20 AM, Naveen Kumar naveenkumarve...@gmail.comwrote:
Process don't share address space when forked.
On Fri, Jun 3, 2011 at 10:40 PM, nitish goyal nitishgoy...@gmail.comwrote:
@ Lalit
You are
when we fork a new process, parent gets the PID of the chid as return value
and child will get 0 as return value.
Same address space is copied and both of them start executing this program
in their own address space.
In Modern OSes 99% of the time child comes first so child process is execute
else
@naveen.. thanks...i got it finally :)
On Fri, Jun 3, 2011 at 10:35 AM, Naveen Kumar naveenkumarve...@gmail.comwrote:
when we fork a new process, parent gets the PID of the chid as return value
and child will get 0 as return value.
Same address space is copied and both of them start executing
But if i have to make sure that hello should be printed first, then i have
to apply synchronization.
please answer my question. how we can semaphores over here
On Fri, Jun 3, 2011 at 11:26 PM, nicks crazy.logic.k...@gmail.com wrote:
@naveen.. thanks...i got it finally :)
On Fri, Jun 3, 2011
to use the semaphores, you have to allocate them using shared memory.
as once you call fork(), both the process will have their own data, so
the semaphores allocated in parent will differ from child. you can
have a shared memory (man shmget) to allocate semaphores and use it..
btw, i think we are
24 matches
Mail list logo