۰
subtitle
البته این که گزینه یک پاسخ هست که واضحه تقریبا.اما در مورد هیپ و استک نکته ای که من در اینترنت دیدم فکر می کنم مساله رو واضح کنه.با انجام fork فضای حافظه کپی نمیشه بلکه Copy-on-Write انجام میشه یعنی به محض این که یکی از دو طرف خواست تغییری در فضای حافظه یا به عبارتی در یکی از صفحات انجام بده اون کپی میشه و برای فرزند و والد به صورت مجزا خواهد بود :
مهمان عزیز شما قادر به مشاهده پیوندهای انجمن مانشت نمیباشید. جهت مشاهده پیوندها ثبت نام کنید.
نقل قول: Each page that is allocated for the process (be it a virtual memory page that has the stack on it or the heap) is copied for the forked process to be able to access it.منبع :
Actually, it is not copied right at the start, it is set to Copy-on-Write, meaning once one of the processes (parent or child) try to modify a page it is copied so that they will not harm one-another, and still have all the data from the point of fork() accessible to them.
For example, the code pages, those the actual executable was mapped to in memory, are usually read-only and thus are reused among all the forked processes - they will not be copied again, since no one writes there, only read, and so copy-on-write will never be needed.
مهمان عزیز شما قادر به مشاهده پیوندهای انجمن مانشت نمیباشید. جهت مشاهده پیوندها ثبت نام کنید.