In a data processing apparatus comprising a real storage having first and second regions each including a plurality of real unit regions, a plurality of storage locations, each storage location being provided for a corresponding one of said real unit regions of said first region, and a single storage location provided commonly for said real unit regions of said second region, a memory allocating method comprising the steps of:
- (a) storing a predetermined storage protection key for said second region in said single storage location before allocating any of said real unit regions of said second region to a virtual unit region;
- (b) determining whether or not a value of a storage protection key requested by a presently executed program for a virtual unit region is equal to said predetermined storage protection key in response to said presently executed program requesting allocation of a real unit region either of said first and second regions to said virtual unit region;
- (c) allocating one of said real unit regions within said first region to said virtual unit region when a result of the determining step is negative;
- (d) writing said storage protection key requested by the program for said virtual unit region into one of the plurality of storage locations corresponding to said allocated real unit region;
- and
- (e) allocating one of said real unit regions within said second region to said virtual real unit region when said result of the determining step is affirmative.