From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,b0b9a5eaad4ab6eb X-Google-Attributes: gid1164f8,public X-Google-Thread: 1014db,37e683828bae12e2 X-Google-Attributes: gid1014db,public X-Google-Thread: 1008e3,37e683828bae12e2 X-Google-Attributes: gid1008e3,public X-Google-Thread: 109fba,37e683828bae12e2 X-Google-Attributes: gid109fba,public X-Google-Thread: f8c65,37e683828bae12e2 X-Google-Attributes: gidf8c65,public From: fred@genesis.demon.co.uk (Lawrence Kirby) Subject: Re: [++] Tight coding Date: 1998/03/02 Message-ID: <888802209snz@genesis.demon.co.uk>#1/1 X-Deja-AN: 329879778 References: <6csl81$rb9@news-rocq.inria.fr> <34F3B7C5.5FD1@earthlink.net> <34F49435.B6307838@hda.hydro.com> <6dbgjv$lg$1@andros.cygnus.com> X-Mail2News-User: fred@genesis.demon.co.uk X-Complaints-To: abuse@demon.net X-Mail2News-Path: genesis.demon.co.uk X-Trace: mail2news.demon.co.uk 888807224 23718 fred genesis.demon.co.uk Organization: none Reply-To: fred@genesis.demon.co.uk Newsgroups: comp.sys.dec,comp.lang.c++,comp.lang.c,comp.lang.modula2,comp.lang.modula3 In article peter@ee.newcastle.edu.au "Peter Moylan" writes: ... >One of my major gripes about C is the strong influence it's >had on operating systems design. > >We have memory segmentation. We've had it for years. What >we don't have are operating systems that make proper use >of the segmentation hardware. > >It's true that the earliest attempts to introduce segmentation >were killed off by considerations of hardware cost and speed. >But those problems were solved some years ago, when the >80286 first appeared. The 8086 and 80286 employ segmentation as a hack to increase memory address space. It is totally inadequate as a vehicle for providing the benefits of a true segmented archetecture. > Once you can get the segmentation >hardware onto the processor chip, and have some space left over >for decent-sized caches, you've got the technology to bring >segmentation to the masses at an affordable cost. Perhaps, but it is the x86 archetecture that has given segmentation a bad name, not any specific programming language. >The catch is that you have all those C programmers demanding >a "linear address space". Why would anyone need a linear >address space? Answer: it's needed if you want to do dirty >tricks with pointer arithmetic. Never mind that those dirty >tricks fell out of favour years ago. The C standard says >that they're legal, so any C compiler that doesn't support >them is not standard-compliant. ANSI C is designed to work in a segmented archetecture, it in no way requires a linear address space. It is invalid in ANSI C to perform pointer arithmetic beyond the bounds of the current object (except a one-past-the-end-rule which isn't a major issue). == and != can be used to compare pointers into different objects but not > >= < or <=. Every variable you define and every object you allocate with malloc/calloc/realloc could be placed in a different segment and that would be a valid ANSI C implementation. The standard was quite carefully crafted to make an efficient implemenattion of the language possible on a segmented archetecture. >For the more modern programming languages, a segmented >address space is superior. There's a natural mapping between >module boundaries and segment boundaries. Unfortunately, >our compilers tend not to take advantage of this, because of >the bias in the operating systems support towards linear >addressing. Maybe because that makes best use of the available hardware. Maybe Unix has some relevance here being the mainstream OS that is "portable" across hardware platforms. >Indeed, the segmentation hardware is not taking off the way >one would have expected. Even Intel, which must have invested >a fortune in developing their segmentation hardware, has >dropped the idea. They keep it in their 80x86 line for >backwards compatibility, but they're not putting segmentation >hardware into their other processors. Presumably they >decided that the demand just wasn't there. More likely the x86 implementation killed any demand that there might have been. >> [...] and we can do a lot better than C. > >Perhaps you hadn't noticed the newsgroups to which this was >cross-posted. Most of us are already doing a lot better >than C. You don't appear to know C well enough to make that judgement. -- ----------------------------------------- Lawrence Kirby | fred@genesis.demon.co.uk Wilts, England | 70734.126@compuserve.com -----------------------------------------