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
728 Views

Similar Articles

[PageSpeed] 25

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:

SetWindowRgn
Hello, I am creating a rounded window using the CreateRoundRectRgn and SetWindowRgn functions, and the results is fine. My problem is that I want to switch back and forth in between the normal window and the rounded window. So when I switch back, I reset the window region but with a new big enough rectangle region. The problem that I have when I comeback to the normal window is that the standard caption bar and its buttons are not redrawn properly, they are kind of basics and lack the style of Windows XP. Is my region too small or is there some activation of standard Caption drawing t...

How do I create internal links in Microsoft Publisher
I am slightly confused here and if someone could help me, I would surely appreciate it. I created a webpage consisting of a navigating buttons at the top of the page; How do I make the buttons links to sections within the document (creating internal links)? Reference: Bookmarks aka Hyperlinking to a place on a page http://msmvps.com/blogs/dbartosik/archive/2006/01/09/81265.aspx In the future I would encourage you to post your web questions to microsoft.public.publisher.webdesign DavidF "nobek" <nobek@discussions.microsoft.com> wrote in message news:46527DFD-5BCC-48D7-8...

Change cell values without creating a new column -- possible?
Hello all, Often in excel I find myself changing data in a column (say add 10 to all items in column A). How I do this is to create a column to the right, put =A1+10 in the cell to the right and drag down. Then I select this column and Paste Special-->Values in the original column. After doing this again and again, I am sure there is a better way that some of you have figured out. Any thoughts? Tim One way: Put 10 in an empty cell. Copy the cell. Select the cells to be incremented. Choose Edit/Paste Special, selecting the Values and Add radio buttons. In article <1178635229.9...

How to create graphs in a monthly report where the base data can change
Firstly an apology if this has been asked for before, I have looked through but am unable to find anything matching my request. Each month I have to produce a report from our business system. Primarily the report consists of many graphs. I have created a report already that each chart references an individual spreadsheet but the downloading from the business system takes a couple of hours as each data set has to be individually compiled and downloaded. It is possible to download all the data in one go, but I am not sure how I go about then linking the data to each graph. Typically the indivi...

create a source table from a special pasted value dynamic crossed table
How to re-create an original doc Excel with only a Dynamic Crossed tab? Example : With this : E F G H A 2 B C 3 D 1 E F 4 How to get this : A F 2 C G 3 D E 1 F H 4 Thanks for your suggestions. Try this link to John Walkenbach's site: http://j-walk.com/ss/excel/usertips/tip068.htm -- Regards, Tom Ogilvy "Arthemus" <jlr@europe.com> wrote in message news:e6830e05.0309290636.3eae2129@posting.google.com... > How to re-create an original doc Excel with only a Dyn...

Overnight processes
Hi, How do I specify a task that is a process like an acid bath that must run for e.g. 10 hours (or more) so that if the process is started at e.g. 11 AM the process is ready next morning for further handling by a person. I have tried to use the 24 hours calendar which works well but if the next task is a similar process I got a problem because the process will start at 9 PM (according to MS project) which is outside normal working hours. but in the real world it must be started during normal working hours? Hope the above is understandable. Thanks Ole Try using elaps...

Sales Process Workflow 11-09-06
Is it possible to re-create the ompleted task of previous stage when I jump back to a previous stage? Afraid not that said.....maybe you could use a callout that could work out you have changed to a prior stage and either recreated or reactivate a previously closed activity. Either way, some coding required. ============================== John O'Donnell Microsoft CRM MVP http://www.crowecrm.com "Lung" <aa@aa.com> wrote in message news:%23zONOICBHHA.4568@TK2MSFTNGP04.phx.gbl... > Is it possible to re-create the ompleted task of previous stage when I > ju...

Unable to create MailBox #2
Hi! I have Microsoft SBS 2000 on my server which also includes Exchange Server 2000. I do user managerment using Active Directory on the server. Recently my exchnage server started giving me following problem: When I create new user or copy over existing user, it creates it fine and it even asks me to create new mail box but when I look in Exchange System Manager, it does not show that users mail box. I am looking in Exchange System Manager, First administrative group, Srever, First storage group, Mailboxes. When I try to open outlook in new user's desktop it gives following error message:...

How to create to fill the default XML elements
I have been trying to find a sample coding in C# of how to create the XmlDocument based on its XSD schema fixed or default element values. I could accomplisht this work somehow like this: (but want to believe that there is far more simple solution for this little problem, so any ideas?) 1) Create the empty DataSet 2) Use ReadXmlSchema methods and read the schema that contains fixed or default element values. 3) Loop each element and fill the element if Column.DefaultValue is not null 4) Create XmlDocument 5) turn off the schema validation 6) Write DataSet to new XmlDocument 7) pass the...

creating an e-mail account
i,m trying to create an e-mail account using Windows Vista Mail and they want me e-mail server(incoming and outgoing) and don't know what those are? What do you suggest i do? "tshepo moloi" <tshepo@creditmatters.co.za> wrote in message news:4F06074A-403D-4299-BFE4-A96B8B40C68F@microsoft.com... > i,m trying to create an e-mail account using Windows Vista Mail and they > want me e-mail server(incoming and outgoing) and don't know what those > are? What do you suggest i do? Windows Mail: Setting up an account from start to finish http://windo...

How to create this form or report
I have a table with the following fields: [LicenseNum], [yrYear], [ttlPaid] which couldh have the following data: A1234 - 2003 - $2,309,390 A1234 - 2004 - $3,209,000 A1234 - 2005 - $4,599,999 G100 - 2005 - $1,999,999 G100 - 2006 - $2,000,000 G100 - 2007 - $999,999 I want a form but preferable a report to display the records like this: License# [Year1] [Year1]+1 [Year1]+2 [Year1]+3 So if I enter 2004 for [Year1], I would get something like this: License# -- 2004 -- 2005 -- 2006 -- 2007 A1234 -- $3,209,000 -- $4,599,999 G100 --- [blank] -- $1,999,999 -- $2,000,000 -- $999,999 T...

Making a query that creates a value base on a table value
Hi I have a table that has two fields (plus a KEY) CustomerName and BUYSELL I want to create a query that shows each record with either "RHS" if the value in BUYSELL = "BUY" or "LHS" if the value in BUYSELL = "SELL" It does not need to save this in a table just needs to show it on running of the query. How do I do this? Probably very easy but my knowledge of access isn't great. So basically now if I create a query to show all data it will show the customer names and either "BUY" or "SELL" next to it. I want th...

Creating a form -
Hi would anyone steer me in the right direction please. I do not have access, only Microsoft exel 2003 I have followed the threats on how to create a form, but will require it modified slightly. (g). Not enough information here to hazard a guess. Please provide a few details on what type of form and slight modifications required. Maybe even a message ID of the threads you followed? Gord Dibben MS Excel MVP On Tue, 24 Nov 2009 14:50:54 GMT, "BNT1 via OfficeKB.com" <u19326@uwe> wrote: >Hi > >would anyone steer me in the right direction pl...

Connection error during credit card processing
Interesting problem: -Internet is wokring fine on all three of our registers. -All non credit card transactions working fine on all three registers. -Credit card transactions working fine on two of the registers, but the third register gets connection error when we try to process credit cards. -Odd thing is that the one register that doesn't work for credit cards is the computer that houses our database. The other two registers are networked to the database on that computer. -We've rebooted everything, power cycled the modem, restarted RMS on all computers. -The only ...

How do I create Trigonometric function graphs?
I need to know if it is possible to create Trigonometric function graphs (charts) in Excel 2003. If so, how is it done? Any help greatly appreciated. G_Freeman76 ...

Unable to create Company in Great Plains 9.00
While creating new Microsoft Dynamics GP Company on " Create Company Information" error message is displayed "Dexterity Runtime has encountered a problem and needs to close. We are sorry for inconvenience" Please suggest resolution Are you running this process from the "server" install of GP? This one install has a special SQL folder in the GP folders that contains scripts needed to create companies. -- Richard L. Whaley Author / Consultant / MVP Documentation for Software Users Get our Free Tips and Tricks Newsletter and check out our books at http://...

Need to programmatically open/process PST files
Hi, all! I'm trying to identify a way that I can programmatically open and process (read, print, etc) Outlook (2k3, 2k7) PST files. I basically need to print out large numbers of email messages and associated attachments for legal processing, WITHOUT the username header splashed across the top of the page. Obviously the cut-and-paste approach and the VBA macro approach are not usable in this scenario. Is there a GOOD reference on using the object model in .Net for Outlook to get me there? I do NOT want to require that Outlook be running at the time, and I do NOT want ...

Create a formula with a moving cell
I need to create a formula that automatically moves to the next cell containing data. I update reports weekly and want a summary formula to include the "new" data in the cell below. Any suggestions? hi what kind of data? numeric? text? you would probably need a dynamic named range to sum. see this site. http://www.ozgrid.com/Excel/DynamicRanges.htm it explains the process. regards FSt1 "iamjbunni" wrote: > I need to create a formula that automatically moves to the next cell > containing data. I update reports weekly and want a summary formu...

Process Server somehow closing automatically
I am running the Process Server on a separate Windows Server 2003 machine. We just purchased the Process Scheduler from mc2 and set it all up. Randomly, three things will happen to the Process Server: 1) while the Process Scheduler is running its list of tasks every night, it will finish them all successfully and everything is fine, 2) the Process Scheduler will finish part of the list of tasks and then somehow the Process Server automatically closes and all other tasks fail, or 3) somehow the Process Server automatically closes itself and nothing ever runs. Any ideas on why this is happeni...

creating a line break
I have about 2000 lines /rows in excel. one of the columns has a code (a class code in our case) Is there any way that I can have the software insert a line break when that class code changes. I would like to isolate the information for each class Thanks Excel 2003 Windows XP Assuming column A is the class code column. Edit to suit any other column. Sub InsertBreak_At_Change() Dim I As Long Dim rng As Range Set rng = ActiveSheet.Range(Cells(1, 1), _ Cells(Rows.Count, 1).End(xlUp)) For I = rng.Rows.Count To 1 Step -1 If rng(I).Row = 1 Then Exit Sub If rng(I) <...

Wizard does not create an Event Procedure for find record combo bo
I've got a MS A 2003 mdb form within which I'd like a pull down to select a record from a table. After going through the wizard the look-up does not work and there is no "Event Procedure" created in the after update section... I've used this in the past with a different installation of Access 2003 without issue.. Thanks in advance! It sounds like you might be trying to use the dreaded *LookupField* in an Access table. You might visit: www.mvps.org/access for a discussion as to why you shouldn't. To achieve the result you seem to be seeking, create a form b...

Create new spreadsheet based on template from macro in Word
Hello, I am trying to put my Excel templates on a menu in Word along with my Word templates, hoping that I can create a new spreadsheet based on my Excel template. I have these two macros which I have tried with no luck: Sub Tryit() Dim xlApp As Object Dim xlWB As Object Dim xlWS As Object Dim cRows As Long Dim i As Long Set xlApp = CreateObject("Excel.Application") Set xlWB = xlApp.Workbooks.Add("C:\Program Files\Microsoft Office\Templates\Timetable\Rule16 fed.xlt") Set xlWS = xlWB.Worksheets(1) End Sub Sub tryitagain() Dim xlWB As Object D...

Create new record
Just wonder if I press the * button on the record selector, is there a new record already inserted? I have a autoincrement field in a record, I would like to know if the new record is really appended so that I can get the latest autoincrement number. ...

How do I create a pick list from a master list in EXCEL
Looking for a way to create a pick list from a master inventory list. I want to be able to print only the items that have been notated without having to select as I go. Is there a report or filter that will allow me to do this? Any help would be greatly appreciated. You can create a column and notate each record with the same identifier (say the letter "P") and then apply an Autofilter (Data > Filter > AutoFilter). Click on the drop- down arrow for that column and select "P". HTH Jason Atlanta, GA >-----Original Message----- >Looking for a way to crea...

Clicking cells on sheet creates Text Box. How do I turn this off?
I have several sheets of a multi sheet workbook that seem to have Auto create on for Text Boxes. When I click on a cell, then try to click the lower right corner to drag the cell ad text box pops up in front of the cell and I cannot drag the cell since the cursor automatically jumps into the text box. This happens on 3 of 9 sheets in about half the columns. The sheets in question originally were clones of a sheet that did not have this problem and other clones don't have the problem. Can not figure out how to turn this off! Help! This sounds like a macro gone awry. If you clos...