This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

non-gcc related question: Language that allows definingnon-swappable regions of code


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]