Wednesday, Jul 17th

Last update12:59:40 PM GMT

Welcome, Guest
Please Login or Register.    Lost Password?

doubt regarding fork()
(1 viewing) (1) Guest
Questions on Open Source - the next big wave!!
Go to bottomPage: 1
TOPIC: doubt regarding fork()
#217
doubt regarding fork() 8 Years, 5 Months ago Karma: 0
In fork() documentation it is written that fork results in 2 copies of the same process. The parent witnon zero return value by fork and child with 0.

I was thinking if the application is having huge memory footprint, then forking will lead to creating a new child process of same huge size? Like If i say i have an application currently running having 20MB memory size.. then the new child will also be 20 MB????

If so, then
(1)fork will be a bad practice in terms of memory use.
(2)Also, what type of applications will be using fork. as i know in unix, piping uses forking only.
admin
Inquisitive
Posts: 10
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#219
Re: doubt regarding fork() 8 Years, 5 Months ago Karma: 0
fork() system call creates threads in a process. we all know that a thread is a LIGHT WEIGHT process. I doesn't create a copy of the process but just creates a new thread with just the needed information like various registers, stack as unique for this process and some data structures, which are for system use, too.

You can take any book on Linux kernel and get more information on fork() system call.
admin
Inquisitive
Posts: 8
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#222
Re: doubt regarding fork() 8 Years, 5 Months ago Karma: 0
aksinghdce wrote:
fork() system call creates threads in a process.
I disagree this statement that fork creates a thread. May be you wanted to explain something else i guess. Its very well written everywhere that fork creates a child process. Even if i agree with your statement( athough i dont agree at all), then with a process all the threads quit. But if a child is created, it will become daemon when its parent quits.

aksinghdce wrote:
we all know that a thread is a LIGHT WEIGHT process. I doesn't create a copy of the process but just creates a new thread with just the needed information like various registers, stack as unique for this process and some data structures, which are for system use, too.

You can take any book on Linux kernel and get more information on fork() system call.


definitely since the threads are part of same process, they have access to process's resources. But the child process creation results in duplication of resources like file descriptors etc

So u still say the fork() will spawn a thread?!
admin
Inquisitive
Posts: 10
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#232
Re: doubt regarding fork() 8 Years, 5 Months ago Karma: 3
Yes the memory segments are copied to the child process as well.. but if the OS makes use of Copy On Write then actual copy of memory is not allocated to the child process unless until it tries to modify the shared data. So I do not think in that case something like entire 200 MB like we have for parent process will be allocated to the child process straight away.
admin
Moderator
Posts: 21
graphgraph
User Offline Click here to see the profile of this user
Rock On!!
The administrator has disabled public write access.
 
#235
Re: doubt regarding fork() 8 Years, 5 Months ago Karma: 0
cool. I too found same statement mentioned all over the web but could not find detailed explanation. I mean how data is shared among child and parent process as each process is having its own Virtual memory.
And as its true that the memory to child will be given when it tries to modify the shared data. So i am confused between normal processes in OS Vs those created with fork(). What r all the differences?
admin
Inquisitive
Posts: 10
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#240
Re: doubt regarding fork() 8 Years, 5 Months ago Karma: 1
Interesting discussion guys..
Abhinav has a valid point... I found dis wiki link:
en.wikipedia.org/wiki/Copy-on-write explaining how COW is implemented for virtual memory.
admin
Inquisitive
Posts: 13
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#302
Pickdfas 7 Years, 7 Months ago Karma: 0
empty"/nnincome tax refund status
Come On Shopping Discount Coupons
ez go golf carts
Thomas Sabo Jewelry
Latest womens clothing blog
wholesale nfl jersey,nhl,mlb,nba jersey
discount and replica coach handbags|coach purse|coach wallets
snooker & pool cues
Christian Louboutin Boots Blog
Shop for cheap Pandora Silver Beads Charms
Pandora Jewelry Blog
2011 New style watches
Pandora beads
baby musical toys
Jordan Shoes Official | Jordan Shoes Official
Buy Ipod Touch 32gb|Ipod Touch 32gb Best Price at Ipod Touch Outlet!
pandora bracelets sale
aspartame side effects | aspartame side effects
leonardo da vinci biography
Best-pandora-necklace-chain-silver-in-2011
early result pregnancy test
ipod touch 32gb
fibre optic christmas tree
family feud online game
women's one piece swimsuits
shopping vibram shoes | shopping vibram shoes
Lcd2008.com Blog - From china Supply!
family feud online game
Wholesale watches online
ghd hair straighteners|ghd mk4|pink ghd|chi flat iron
tankless water heater reviews
antique chest of drawers
hot tools curling iron
New style pandora necklaces
Buy-authentic-pandora-bracelets-wholesale-online
best hip hop songs
sneakers sale online
ugg shoes online sale
belly dancing costumes
wholesale nike online blog
new only christian shoes | new only christian shoes
Best-silver-plate-pandora-style-snake-chain-wholesale
home audio cd players
pandora charm bracelets
cheap shoes online sale blog
power tools cordless drills
guitar stuff for sale
walking with the dinosaurs
Lcd2008.com Wholesale Jordan Shoes | Just another WordPress site
financial risk management software
admin
Inquisitive
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1
get the latest posts directly to your desktop

Web Hosting