Create Process

if i call fork() / CreateProcess
what is/are duplicated?
i know that data space is duplicated for sure
how about code space?
the code space can be shared to save space....
but the new process may need to do rebasing...
so...does the code space also shared?

thx


0
10/7/2003 3:28:24 PM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
709 Views

Similar Articles

[PageSpeed] 8

Action wrote:

>if i call fork() / CreateProcess
>what is/are duplicated?
>i know that data space is duplicated for sure
>how about code space?
>the code space can be shared to save space....
>but the new process may need to do rebasing...
>so...does the code space also shared?

There is no fork in Windows. CreateProcess creates a separate process.
Processes share code backed by images (EXEs and DLLs) on disks, provided the
code sections can be loaded at the same logical addresses within the
processes. If not, then rebasing is required, and it all happens behind the
scenes, of course. AFAIK, rebasing can only ever be an issue for DLLs, which
can fail to load at their preferred load addresses, due to something else
occupying that space.

-- 
Doug Harrison
Microsoft MVP - Visual C++
0
dsh (2498)
10/7/2003 4:46:04 PM
does it mean
|data|code|
after createprocess
|data|code|child data|
??
thx..



"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:v0r5ov0tb36se3lk26jt7a4kqjekrhv6id@4ax.com...
> Action wrote:
>
> >if i call fork() / CreateProcess
> >what is/are duplicated?
> >i know that data space is duplicated for sure
> >how about code space?
> >the code space can be shared to save space....
> >but the new process may need to do rebasing...
> >so...does the code space also shared?
>
> There is no fork in Windows. CreateProcess creates a separate process.
> Processes share code backed by images (EXEs and DLLs) on disks, provided
the
> code sections can be loaded at the same logical addresses within the
> processes. If not, then rebasing is required, and it all happens behind
the
> scenes, of course. AFAIK, rebasing can only ever be an issue for DLLs,
which
> can fail to load at their preferred load addresses, due to something else
> occupying that space.
>
> -- 
> Doug Harrison
> Microsoft MVP - Visual C++


0
amuro (9)
10/8/2003 5:52:17 AM
babylon wrote:

>does it mean
>|data|code|
>after createprocess
>|data|code|child data|

I'm not sure what you're saying there. The two processes are completely
independent, and the creating process has no access to the child's code or
data, which live in a different address space.

>??
>thx..

To put it very briefly and over-simplified, the Windows loader maps the
entire EXE file and any DLLS it implicitly links to into the newly created
process's address space, and then the paging system takes over. So, yes, the
data sections contained in the images are shared between processes. However,
pages containing writeable data are marked copy-on-write, so that each
process using the data really does have its own private copy, but only as
necessary. You can read more on this here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/memory_protection.asp?frame=true

Richter describes what happens when you call CreateProcess in more detail in
his chapter on memory-mapped files in "Programming Applications for
Microsoft Windows".

-- 
Doug Harrison
Microsoft MVP - Visual C++
0
dsh (2498)
10/8/2003 7:07:20 AM
so u mean that both processes have different code virtual address and data
virtual address
but both process's code/data addresses are initially pointing to the same
physical memory
when one of the process change sth (e.g. assign a = pid()), a new physical
page is copied.
so...the code's physical address is actually shared as both processes can't
change anything in the code address...

thx..


"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:7ua7ovkkiapmrrbo1vusv0tf6pvvnk8qbn@4ax.com...
> babylon wrote:
>
> >does it mean
> >|data|code|
> >after createprocess
> >|data|code|child data|
>
> I'm not sure what you're saying there. The two processes are completely
> independent, and the creating process has no access to the child's code or
> data, which live in a different address space.
>
> >??
> >thx..
>
> To put it very briefly and over-simplified, the Windows loader maps the
> entire EXE file and any DLLS it implicitly links to into the newly created
> process's address space, and then the paging system takes over. So, yes,
the
> data sections contained in the images are shared between processes.
However,
> pages containing writeable data are marked copy-on-write, so that each
> process using the data really does have its own private copy, but only as
> necessary. You can read more on this here:
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/memory_protection.asp?frame=true
>
> Richter describes what happens when you call CreateProcess in more detail
in
> his chapter on memory-mapped files in "Programming Applications for
> Microsoft Windows".
>
> -- 
> Doug Harrison
> Microsoft MVP - Visual C++


0
amuro (9)
10/9/2003 1:44:59 AM
actually, i wanna ask why the output is
parent:0x10bcc
parent: 11 add: 0xffbefad0
Child:0x10bcc
parent: 10 add: 0xffbefad0
--------------------------------
for the following codes
--------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <iostream>

using namespace std;

void abc()
{
}

int main()
{
  pid_t p = fork();
  int z = 0;
  if (p == 0)
  {
    z=10;
    cout <<"Child:"<< (void*)&abc << endl;
    cout <<"parent: "<< z << " add: " << (void*)&z << endl;
  }
  else
  {
    z=11;
    cout <<"parent:"<< (void*)&abc << endl;
    cout <<"parent: "<< z << " add: " << (void*)&z << endl;
  }
}


"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:7ua7ovkkiapmrrbo1vusv0tf6pvvnk8qbn@4ax.com...
> babylon wrote:
>
> >does it mean
> >|data|code|
> >after createprocess
> >|data|code|child data|
>
> I'm not sure what you're saying there. The two processes are completely
> independent, and the creating process has no access to the child's code or
> data, which live in a different address space.
>
> >??
> >thx..
>
> To put it very briefly and over-simplified, the Windows loader maps the
> entire EXE file and any DLLS it implicitly links to into the newly created
> process's address space, and then the paging system takes over. So, yes,
the
> data sections contained in the images are shared between processes.
However,
> pages containing writeable data are marked copy-on-write, so that each
> process using the data really does have its own private copy, but only as
> necessary. You can read more on this here:
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/memory_protection.asp?frame=true
>
> Richter describes what happens when you call CreateProcess in more detail
in
> his chapter on memory-mapped files in "Programming Applications for
> Microsoft Windows".
>
> -- 
> Doug Harrison
> Microsoft MVP - Visual C++


0
amuro (9)
10/9/2003 2:14:18 AM
babylon wrote:

>actually, i wanna ask why the output is
>parent:0x10bcc
>parent: 11 add: 0xffbefad0
>Child:0x10bcc
>parent: 10 add: 0xffbefad0
>--------------------------------
>for the following codes
>--------------------------------
>#include <sys/types.h>
>#include <unistd.h>
>#include <iostream>
>
>using namespace std;
>
>void abc()
>{
>}
>
>int main()
>{
>  pid_t p = fork();
>  int z = 0;
>  if (p == 0)
>  {
>    z=10;
>    cout <<"Child:"<< (void*)&abc << endl;
>    cout <<"parent: "<< z << " add: " << (void*)&z << endl;

s/parent/Child/

>  }
>  else
>  {
>    z=11;
>    cout <<"parent:"<< (void*)&abc << endl;
>    cout <<"parent: "<< z << " add: " << (void*)&z << endl;
>  }
>}

Your program uses some "fork" function, and Win32 doesn't provide anything
like Unix's fork. You'd have to consult the documentation you have to
understand what it's doing. I guess maybe you're building a program for the
Posix subsystem, or Cygwin, or Services for Unix, or some other Unix
work-alike. The addresses you're printing are virtual addresses, of course.
Just because they're equal in the parent and child doesn't necessarily mean
they refer to the same physical page of memory, and they clearly don't for
the pages containing 'z'. If they did, the parent and child would observe
the same value, but your output demonstrates the variables have the correct,
different values in the parent and child.

-- 
Doug Harrison
Microsoft MVP - Visual C++
0
dsh (2498)
10/9/2003 3:31:34 AM
Reply:

Similar Artilces:

Launch External Process from Menu/Toolbar?
My organization is preparing to upgrade from 7.5 to 8.0. In 7.5, we added palette items that launched Excel and opened a specific workbook (via Setup>>Company>>Palettes). I've found no way to add a menu item in 8.0 that would launch an external process. What are the options for doing this in 8.0? Thanks for any assistance. Mark Set them up as shortcuts..and if you use User Classes, place the shortcuts under each User Class..you will probably need to logged on with 'sa' to do this. "FBMark" wrote: > My organization is preparing to upgrade from 7.5 ...

The ActiveX control could not be created
Hello, In the Project Center of PWA 2007 + SP2 and Aug CU, I did: Actions > Export Grid to Excel. But I got the error: "The ActivX control on which this feature depends could not be created. Because of this error, you can only copy the XML data to the clipboard. Do you want to continue?" How/where can I install this ActiveX control? Thanks for your help. Depending on your IE security settings, it should prompt you to install the ActiveX control. Have you set the site as a trusted site within IE? - Andrew Lavinsky Blog: http://blogs.catapultsystems.co...

How to create a table to qualify a qty discount in exel
Hi i'm creating a workbook to orginize stock, i'm not sure of how to create a table to give varying degress of discount according to the quatity bought ie: 5 items or less = no discount, 6 to 11 items =2% discount and so on, i have used an if statement so far but i'm not sure how it is meant to work in relation to the products and customers sheets, how does it all work together. Any help & guidence would be much appreciated. You can create yourself a lookup table, and use the vlookup formula. See: http://www.officearticles.com/excel/vlookup_formulas_in_microsoft_exce...

Create Exchange 2007 mailbox
Hi! :) We use a vbscript to create users. Here are the lines of code in the script that creat the user account. The password is also set and some groups added... Set objUser = objUserOU.create("user", "cn=" & strEmpid) objUser.Put "SAMAccountName", strEmpid objUser.Put "givenName", strFirstName objUser.Put "sn", strLastName objUser.Put "displayName", strLastname & " " & strFirstName objUser.AccountExpirationDate = DateAdd("d", 1, CDate(strEndDate)) objUser.Put "userPrincipalName&q...

Creating Groups
Hello, Using Outlook2002, is there a way to create groups so that I can select the group name for a mailing rather than the individual members? I can't figure it out and it seems that years ago you could do that. Thanks for any help and God Bless, Mark A. Sam File > New > Distribution List -- Russ Valentine [MVP-Outlook] "Mark A. Sam" <msam@Plan-It-Earth.Net> wrote in message news:%23Y%23XQ8K5FHA.2092@TK2MSFTNGP12.phx.gbl... > Hello, > > Using Outlook2002, is there a way to create groups so that I can select > the > group name for a mailing ra...

how do i create subset and union in XPath Query
Hi Friends, I need a XPath query, whcih ll return me subset of data.... check below xml stream <label id="MyExpenseDetails_lbl" xlink:role="terseLabel">Short Expense Details</label> <label id="MyExpenseDetails_lbl" xlink:role="displayLabel">Expense Details</label> <label id="InternalExpense_lbl" xlink:role="displayLabel">Internal Expense</label> <label id="ExternalExpense_lbl" xlink:role="terseLabel">Short External Expense</label> See above xml data having 4 label ...

How do I create a Bell Curve Graph in Excel
I am trying to create a Bell Curve Graph in Excel but have ground to a halt, I using Excel 9 Fratton, This example at this site should help: http://www.pdbook.com/index.php/excel/charting_a_normal_distribution/ ---- Regards, John Mansfield http://www.pdbook.com "fratton" wrote: > I am trying to create a Bell Curve Graph in Excel but have ground to a halt, > I using Excel 9 See Normal curve http://www.tushar-mehta.com/excel/charts/normal_distribution/index.htm -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Off...

Cannot create a key uder HKEY_USERS !
Hi, I want to make a new key under HKEY_USERS. I use RegCreateKeyEx(HKEY_USERS, "Test\\SOFTWARE", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dw); However the function always returns - "The parameter is incorrect." . If I change HKEY_USERS to HKEY_CURRENT_USER the key gets created. I can not add a new key under HKEY_USERS even when I use Regedit.exe . I am testing on a Windows XP professional PC . Can anyone tell me what is wrong? Thanks! HKEY_USERS is restricted to Admins and the OS. I'm betting you do not have sufficient privileg...

Creating drop down lists with multiple options?
I am trying in vain to create a drop down list where users can select more than 1 choice. For example, if the choices in a list which i named are as follows: Blue Red Green Yellow Purple How does one have the option to select any of the colors by themselves or any combination of all of them up? For example, if the question is what is your favorite color? How can a user choose Blue OR Red and Blue OR Red, Blue and Green and so on? Any help would be appreciated. That will require multiple cells. One cell will only hold 1 value. Any single cell solutions are going ...

Attempting to create a CRM Test Environment
I am attempting to create a CRM test environment using the database name "Adventure Works Cycle". After the database is created and the users added I have attempted to import the XML schema and form changes from our Production Environment but everytime I do this I recieve the error "An Error has occurred. For more information, contact your system administrator". This error appears when I click on the "Services" tab. I know that it is attempting to query the database at this time. I am able to click on the "New Case" button and bring up the p...

How to create a "really" transparence MFC control?
I wrote a D3D app based on the MFC dialog,the app's draw frequency is 30FPS.It has a main dialog,i create the D3D device on it,also i create some sub dialogs and controls on this main dialog.When i run this app, some errors appear.When i click or move the sub dialogs and controls it reflash on the background(I think the MFC's draw frequency unequal to the D3D app's draw frequency cause this problem), this bring on the bad effect.Is there any methods let this sub dialogs and controls didn't reflash or redraw themself to be "really" transparence:only receive or send...

simple xsl for creating aspx page
Hello I know nothing of XSL but was wondering if it was possible to do the following: Given an XML template: <template> <register TagPrefix="whatever" TagName="Template" src="Common/Template.ascx" /> <page language="c#" /> <usercontrol tag="whatever:Template" ID="header" Runat="server" Type="header" /> <form id="form1" method="post" runat="server"> <h1>some text here</h1> testing </form> <usercontrol tag="whatever...

COM Proxy timeout error when creating new opportunity
I get an exception when creating a new opportunity in CRM 1.2: [COMException (0x80040e31): Timeout abgelaufen] Microsoft.Crm.Platform.ComProxy.CRMOpportunityClass.CreateAndRetrieve(CUserAuth& Caller, String InOpportunityXML) +0 Microsoft.Crm.Application.Platform.Opportunity.InternalCreateAndRetrieve(String xml, String columnSet) Microsoft.Crm.Application.Platform.Entity.CreateAndRetrieve() Microsoft.Crm.Application.Forms.AppForm.RaiseDataEvent(FormEventId eventId) Microsoft.Crm.Application.Forms.EndUserForm.Execute(Entity entity) Microsoft.Crm.Application.Forms.Customi...

Create a new e-mailactivity
Hi! I wonder if there is a chance to create a new activitytype like salesmeeting or if I only can use the existing ones...? You cannot create new types of Activity, and so are restricted to the original eight. However it quite common to reuse one of the original types - such as renaming the 'Fax' activity to 'Sales Meeting' or something similar. Typically I'd reccommend adding a Category or Meeting Type field to the Appointment Entity Type and then customising the Views or ISV.Config to fit your requirement, as whilst renaming the existing types can work it is a bi...

How to create Office Sta 03 from a picture? #2
Just posting one help question, here's the second: Again regarding Creating Stationary for Outlook?! Again, reminding those I'm no "geek" in any respect, wishing one day I was, but it "ain't happened yet"! I depend & reply on those with the knowledge - so someone - please help! ONE TIME I was successful in taking an image, inserting into PAINT, fix'g the way I wanted it to show itself, saving same as an image, with the apparent default being Bitmap, wanting to save as another type - mainly that of Internet Explorer! HOW do I do it? As shared, ...

how to create a calculated field from another calculated field?
In a pivot table report I would like to add a calculated field that is like the following: = count( columnA ) / count ( columnB) But when I create a calculated field like the above, all I get is a value of 1 in every row of the pivot table. I realize after some experiments, its really performing = count( sum ( columnA ) ) / count( sum ( columnB ) ) So , how do I get what I want? ...

Remove Ability to Create Contacts
We have a third-party plugin tool (which links with our CRM) for Outlook 2003 which has its own "Create New Contact" wizard we want people to use instead of creating a new contact with Outlook. The question is, how do we remove their ability to create a new contact using Outlook's default contact creation screen? It would be nice if we could remove the button(s) used for creating a new contact, but the problem is the multi-function button on the left-hand side of the toolbar - when you're on the contact screen it become a Create New Contact button. But removing the entire ...

create a cell that accumulates, numbers from another cell...
I need to know how to have a entery cell that can send number values to a cell that accumilates there sum .the entries in the entery cell can be changed and the recieving cell just keeps adding up. The entry cell can be left blank and the sum remains in recieving cell. -- Thanks sombull http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "sombull" <sombull@discussions.microsoft.com> wrote in message news:41021B44-363C-418C-9A4F-6CD126431698@microsoft.com... > I need to know how to have a entery cell that can send number values to a > cell ...

Sorry to create a new post, but I have tried the other posts' suggestions... can't use install new Office 2004?
Hello there, I'm hoping someone can please help me to help a friend who is in need. I am in Germany to attend his wife's unexpected funeral and help him out with his 4 young children and his small business. Well, one of the things I did was convince him to switch from an old PC to a new iMac. And then I got him to buy a full version of Office 2004 rather than use Apple's Windows emulator and run his old PC version of Office. So the new Mac Office 2004 arrives, and one of his 'know it all' friends puts the disc in the iMac and starts the installation - without first removin...

How to create and delete recovery points for DPM via PowerShell
Knowing how to manipulate DPM by way of PowerShell can come in handy in many situations. For example, I had a case to where I was troubleshooting the DPM console that was crashing and there was a concern as to whether or not recovery points where being made for specific protection groups. Using the PowerShell command we could not only verify this, but we could create a recovery point to any protection group we wished. Another example would be if you wanted to delete some recovery points to reclaim some disk space. Recovery points cannot be deleted by the GUI so you have to use P...

how to create a memorandum
i need to know how to create a memorandum for my excel, but i need to do it in word. You can use Paste Special to link an Excel range into Word. -- Stefan Blom Microsoft Word MVP "tamara" <tamara@discussions.microsoft.com> wrote in message news:DFC8B2F9-D808-40DA-9B22-C7445D486545@microsoft.com... >i need to know how to create a memorandum for my excel, but i need to do it > in word. ...

Access/Excel: Create multiple Lines/Column out of one mulit-line Column?
Hallo everyone! I spent a lot of time today searching for a response to my question but I had unfortunately no success. The problem is the following: I have got an Access-table called Employee with an ID and one corresponding Field/Column called comment. These comments are stupidly multi-line (separated by a Return). It's my aim to have access (he he, wordplay) to these two fields in Excel whereas the field shouldn't be longer that 255 characters. I considered three solutions: The table could be changed after being exported to excel in the following two ways: - Multiple Comment Column...

Programatically creating text box
Hi all..I need help regarding creating the edit box programatically.. I have drawn a movable rectangle in a view.Now how i want to make that rectangle editable..can any body show me some pointer/sample code? I was cocoa programmer. i know how to do this in mac os..but i dont know how do i o it in MFC.. please help me I took the source code for drawing from following link : http://www.codeproject.com/miscctrl/diagrameditor.asp Thanks in advance CEdit editbox; when you need it editbox.Create(...parameters here...) and when you are done with it, editbox.DestroyWindow(); or if you want ...

Creating array from matrix with blank values
I have a matrix in the following format 1 X X X X X X X X X X X 3 X X X X X 4 X X X X X X X X where 'X' is a blank cell. I need to get the data in the form 1 3 4 Any suggestions? I tried a nested if statement but it doesn't work since there are more than 7 ifs. Andryll, If there is only one value in each row, then simply using =SUM(A1:L1) where A1:L1 is your top row, then copied down for two more rows, will give you your desired result. HTH, Bernie MS Excel MVP <Andryll.Davis@gmail.com> wrote in message news:1160141392.644344.173360@i3g2000cwc.googlegroups.com......

Create a PDF Doc with CRM Data
Hi, I would like to be able to create a standard contract document to PDF with the data from a form or Prospect Client, and include of text, images (logo of my society ...) and so on ... Thanks Bernard I can think of a few ways. One would be to use SQL reporting services, which (I think) can save to PDF. The other option would be Office 2007 which can save to PDF (you might have to download the option form Microsoft), which means you could just do a mail merge, and print the file to PDF. If you are using Office 2003 you can get free PDF printers (for example CutePDF) which would al...