Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to run a Linux application and all I want to run is this one application off of boot. I need networking and that's all (no display, peripherals, etc.). I want no other applications running so that the application I run has 100% of the CPU. Is this possible?

share|improve this question
    
Probably should be migrated to Unix & Linux –  sbtkd85 Aug 8 '11 at 17:31
6  
@sbtkd85 No. The question is on-topic here and therefore should stay here. –  slhck Aug 8 '11 at 17:32
    
It won't be able to grab 100% of the CPU seeing as your OS still needs some resources. –  maxmackie Aug 8 '11 at 17:44
    
@MaxMackie Obviously, but I would like the OS to only take over on behalf of the application (for networking purposes for instance). –  dschatz Aug 8 '11 at 17:45
1  
You realize that even with a desktop environment loaded, but sitting there idle, it isn't using any cpu time right? And the ram it is using is subject to being swapped out if other applications demand it. –  psusi Aug 8 '11 at 18:28

5 Answers 5

There are some system applications which are must be run, besides them, sure, you can dedicate the rest of the computer resources to that application. To have the very minimum you can take a look at really small Linux distros like TinyCore Linux etc.

Also it would depend on application itself too, what services it requires besides the network etc.

I think if you can provide more specific information you would get more detailed response.

Like what kind of app etc.

share|improve this answer
    
My application uses the pthread library to run some mulithreaded workload (arithmetic operations) and can be instructed to do different calculations based on input from tcp/ip. Looking at TinyCore Linux, it boots into a full desktop environment, which I don't want. –  dschatz Aug 8 '11 at 17:36
    
TinyCore has a smaller brother called MicroCore. No GUI, check it out. –  maxmackie Aug 8 '11 at 17:45
1  
@MaxMackie I actually want no interface on the machine itself outside of the tcp/ip stack. The application can block on a port and can be controlled via tcp packets sent to that port. –  dschatz Aug 8 '11 at 17:55
1  
I'd recommend an environment with little services running (check this out linuxhelp.blogspot.com/2006/04/…) and hardly anything other than your application and it's dependencies installed. –  maxmackie Aug 8 '11 at 18:01
1  
@dschatz well, then you need to hack kernel, remove everything else and compile your app into it. no bash no anything else. just your app..lol. –  bakytn Aug 8 '11 at 18:33

It sounds like you are trying to set up a kiosk. Most guides around the Internet focus on a web browser like Firefox as the single application that runs. Take a look at this guide for ideas.

share|improve this answer
2  
Hmm, I'm really just trying to run a single application with networking. I don't want any X and as few other applications running as possible. I don't see how this restricts all the unnecessary daemons from running. –  dschatz Aug 8 '11 at 17:43
    
can the application run without X though? –  Journeyman Geek Dec 6 '11 at 3:37

You can certainly run just one user application after booting the kernel. But it will not have 100% of the CPU because there will be some other kernel-related processes that must exist. This is commonly done in embedded-Linux devices, e.g. wireless routers. I also have first-hand experience doing this for a multi-threaded application.

Once the kernel has booted, an initialization or startup script is run. Read up on Linux runlevels and the init process. There are various startup schemes in use, so it is not possible to be specific. But Linux will allow you to configure exactly which applications and daemons will execute for your situation. Other than a startup file at root, the files that need modifying are in /etc, and in particular /etc/init.d

BTW unless you're somekind of superprogrammer or before you get a remote GDB server running, you're going to need somekind of debug console (either the PC console or a serial port) for your application. This will allow you to be notified of seg faults, bus errors and assertion failures. So plan on having somekind of "peripheral" besides "networking".

share|improve this answer

you can start kernel with init=/path/to/myapp parameter defined in your bootloader.

share|improve this answer
    
This is a rather extreme solution. Replacing the startup script with the user application will have the application running without networking, without any filesystems other than the rootfs mounted (no sysfs or proc or tmpfs), and possibly some device nodes will not be created. –  sawdust Aug 9 '11 at 15:33
    
@sawdust: Totally agree. But the question was also bit extreme... :-) –  Michał Šrajer Aug 9 '11 at 17:05

If you really want nothing but the Linux kernel, networking, and your application, the only way to do it is this:

  • You will need to make your application a kernel module - make sure it is debugged and well tested. This kernel module would have to initialize things typically done via userspace such as set interface IP addresses and all that good stuff.
  • You will need to download and configure (make menuconfig) your own custom kernel and remove all features that are not related to running the system and networking. You will want to disable to block layer, I don't know how to do this on recent kernels through make menuconfig.
  • You then need to include your module into the kernel so it is included as part of the kernel and not a loadable module. You would likely disable loadable modules in the step above. If you know enough C/C++ to create a kernel module this should be easy for you.
  • You need to modify whatever part of the kernel that panics if init fails to not do that, or be prepared to live with 1 extra user-space process.

I know it's possible for kernel modules to create processes - a simple ps aux would show many on a typical system (they are all in brackets). You probably want your module to create a kernel process. To get rid of all kernel-created processes besides yours, you'll need to disable threads [kthreadd], power management [pm], the event layer [events], and others.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.