public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* non-gcc related question: Language that allows defining non-swappable regions of code
@ 2002-09-01 22:16 Kristis Makris
  2002-09-01 22:31 ` Rene Rebe
  0 siblings, 1 reply; 3+ messages in thread
From: Kristis Makris @ 2002-09-01 22:16 UTC (permalink / raw)
  To: gcc

Hello,

This is more of a theoretical question that does not directly relate to
gcc and it's development, and I hope it's not too intrusive. I was
wondering if there exists a language, or an extension to a language,
that allows specifying blocks of source code that should be loaded by
the underlying operating system to a memory area that cannot be swapped
out of memory.

My reasoning for looking into such a language extension is that a
low-end machine with inadequate memory inadvertedly has the side-effect
of swapping. Even though some processes can be assigned a higher
priority while running, it may still take them some time to swap in if
they weren't in use for a while. Thus, it could be beneficial
if one could define while writing a program certain chunks of code that
the programmer deems should never be swapped out of memory. 

Using the c language as an example, the source could be similar to:

/* This function should not be swapped out */
non_swappable void read_input()
{
 ...
}


or even:


void read_input() {
 /* do stuff */

 try non_swappable {
 scanf("%s", buf);
 } 

 try non_swappable {
 scanf("%s", buf2);
 } on_fail {
  /* execute this if the request to be loaded in non-swappable
     memory pages fails */
 }

 /* do more stuff */
}


It could be possible to define possible actions to be taken by the os to
the request of loading a chunk in a page that is marked as
non-swappable, such as (in very high-level terms): "must load in
non-swappable area or exit", "try to load in non-swappable area, but if
none is available then still load but execute this following chunk of
code".

From a theoretical perspective, I'm wondering if it's possible (or not)
to bring a language and an OS closer, allowing for more OS
features/events/actions to be specified in the source of a userspace
program, with the above as an example. A practical approach to the
pragmatics of this would require having the compiler of a language with
such asn extension generate an additional section in the elf binary that
the loader of an OS would know how to interpret, if it included support
for this additional language-extension-specified feature.

I'm also wondering if there exists some library that could provide a
similar end result, or perhaps a system call some operating systems
support that will allow a process to make such requests at run-time. I'd
be interested to know about any languages and/or compilers that support
something similar to this, and of course the opinion of gcc developers
on the feasibility and/or applicability of such an extension. I would be
interested in researching this with a proof of concept set as a goal,
modifying a gcc frontend and most definitely the backend, and the linux
kernel to support this feature.

Thanks for your attention and comments.
Kristis

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: non-gcc related question: Language that allows defining non-swappable regions of code
  2002-09-01 22:16 non-gcc related question: Language that allows defining non-swappable regions of code Kristis Makris
@ 2002-09-01 22:31 ` Rene Rebe
  2002-09-02 15:13   ` Bernd Jendrissek
  0 siblings, 1 reply; 3+ messages in thread
From: Rene Rebe @ 2002-09-01 22:31 UTC (permalink / raw)
  To: devcore; +Cc: gcc

Hi.

On: 01 Sep 2002 22:16:24 -0700,
    Kristis Makris <devcore@freeuk.com> wrote:
> Hello,
> 
> This is more of a theoretical question that does not directly relate to
> gcc and it's development, and I hope it's not too intrusive. I was
> wondering if there exists a language, or an extension to a language,
> that allows specifying blocks of source code that should be loaded by
> the underlying operating system to a memory area that cannot be swapped
> out of memory.

[...]

You might to visit the man-page of:

mlock                (2)  - disable paging for some parts of memory
mlockall             (2)  - disable paging for calling process
munlock              (2)  - reenable paging for some parts of memory
munlockall           (2)  - reenable paging for calling process

Such features have nothing to do in a programming language ...

k33p h4ck1n6 -- René

--  
René Rebe (Registered Linux user: #248718 <http://counter.li.org>)
e-mail:   rene.rebe@gmx.net, rene@rocklinux.org
web:      www.rocklinux.org, drocklinux.dyndns.org/rene/

Anyone sending unwanted advertising e-mail to this address will be
charged $25 for network traffic and computing time. By extracting my
address from this message or its header, you agree to these terms.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: non-gcc related question: Language that allows defining non-swappable regions of code
  2002-09-01 22:31 ` Rene Rebe
@ 2002-09-02 15:13   ` Bernd Jendrissek
  0 siblings, 0 replies; 3+ messages in thread
From: Bernd Jendrissek @ 2002-09-02 15:13 UTC (permalink / raw)
  To: Rene Rebe; +Cc: devcore, gcc

On Mon, Sep 02, 2002 at 07:31:47AM +0200, Rene Rebe wrote:
> On: 01 Sep 2002 22:16:24 -0700,
>     Kristis Makris <devcore@freeuk.com> wrote:
> > Hello,
> > 
> > This is more of a theoretical question that does not directly relate to
> > gcc and it's development, and I hope it's not too intrusive. I was
> > wondering if there exists a language, or an extension to a language,
> > that allows specifying blocks of source code that should be loaded by
> > the underlying operating system to a memory area that cannot be swapped
> > out of memory.
> 
> [...]
> 
> You might to visit the man-page of:
> 
> mlock                (2)  - disable paging for some parts of memory
> mlockall             (2)  - disable paging for calling process
> munlock              (2)  - reenable paging for some parts of memory
> munlockall           (2)  - reenable paging for calling process
> 
> Such features have nothing to do in a programming language ...

gcc-help@gcc.gnu.org next time...

You can use __attribute__((section("unswapped"))) in conjunction with
this.  There's nothing special about the name "unswapped"; just make sure
your output file format supports arbitrary section names.

Consider using a linker script to place whole modules in unswapped regions.
That does not require language extensions either.

Look at linux kernel code - it uses section attributes extensively, as well
as a linker script so the linker knows what to do with these sections.

bernd

--
berndfoobar@users.sourceforge.net is probably better to bookmark than any
employer-specific email address I may have appearing in the headers.
  Vanity page: http://www.tsct.co.za/~berndj/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-09-02 22:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-01 22:16 non-gcc related question: Language that allows defining non-swappable regions of code Kristis Makris
2002-09-01 22:31 ` Rene Rebe
2002-09-02 15:13   ` Bernd Jendrissek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).