Two problems in Petzold's book 
Author Message
 Two problems in Petzold's book

Hello. I am reading Petzold's Programming Windows, fifth edition,
and I have two questions here. Will you please clear my doubts?
1. This passage is on page 1264:
" Windows erects a wall around the address space of a Win32 process.
Normally ,data in
   an address space is private and invisible to other processes. But running
multiple instances
   of STRPROG shows that STRLIB has no trouble sharing its data with all
instances of the
   program."
   Question 1:  " process " seems to be a alias of " instance" in the above
statement.
                         Are they really the same thing?
2. This is on page 1254 and 1255:

    #pragma  data_seg ("shared")
     int    iTotal = 0;
     WCHAR szStrings [MAX_STRINGS] [MAX_LENGTH + 1 ] = { '\0' } ;
     #pragma  data_seg ( )
     #pragme  comment ( linker, "/SECTION: shared, RWS")
     Question 2: Do the above statements ask Windows to create a data
segment
                        ( notice that Petzold use" data section " instead of
data segment )
                        for the program? The S in RWS seems to mean
privilege level 3
                        since a data segment with ring 3 can be accessed by
ones with any
                        ring levels.



Tue, 19 Aug 2003 07:35:28 GMT  
 Two problems in Petzold's book

Quote:
>    Question 1:  " process " seems to be a alias of " instance" in the
above
> statement.

Yes, Windows runs instances of processes. In Win16 the distinction between
processes was less definite, so the word instance was used to indicate one
copy of a program you'd run by double-clicking in Program Manager.

Quote:
>      Question 2: Do the above statements ask Windows to create a data
segment
> ( notice that Petzold use" data section " instead of
> data segment ) for the program?

In 32-bit Windows there is a difference between segments and sections. In
protected mode, a segment is a block of code or data with specific access
levels and flags given to it. There are usually two segments for user code
and data, which start at virtual address zero and are 4GB in size.

Because of this Microsoft changed the terminology used in the EXE file
format for Win32. A block of code or data in an EXE file no longer
corresponds to a segment in memory -- it is just a linear block of code and
data. For that reason they named them "sections" in the PE file format.

Quote:
> The S in RWS seems to mean
> privilege level 3 since a data segment with ring 3 can be accessed by
> ones with any ring levels.

The S in RWS stands for "shared": when a new copy of your application is
started, Windows maps that section to the same physical memory as the
previous instance; hence, the memory is shared. Ordinarily Windows would
allocated separate memory for each section in each copy of the application.

Yes, PL3 memory can be accessed by any other ring. But what you're concerned
with here is whether the memory can be accessed by other copies of your
application; you don't need to get involved in kernel details when you're in
user mode.



Tue, 19 Aug 2003 19:47:02 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. GDI mappping mode in Petzold's book

2. Charles Petzold's Programming Windows,good?

3. read two sets of data from two spread sheet files to two arrays problem

4. Help with Ullman's ML book problem

5. Still having problems with scripts in Welch's book

6. problems with scripts from Welch's book

7. two definitions of 'cyclic'?

8. Angles don't map nicely to two's complement turns

9. TWO 'HIGH-PRICED' ADA TOO

10. Two more books on APL

11. Two Books

12. FS: Two Clipper books

 

 
Powered by phpBB® Forum Software