LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to boot custom application on CPU #2 (https://www.linuxquestions.org/questions/programming-9/how-to-boot-custom-application-on-cpu-2-a-399081/)

yspm 01-03-2006 10:50 AM

How to boot custom application on CPU #2
 
On a 2 CPU (Xeon) Intel PC, I wish to:
1) Boot RedHat on CPU #1
2) Boot a custom application (no OS) on CPU #2

Has anyone ever done something like this? What approach should I take? Can I boot the 1st CPU in BIOS, then the second from an application?

Also, my custom application will need to do I/O on a PCI NIC device. Do you think that canned Linux drivers for PCI and the NIC will be portable to the OS-less application?

Thanks in advance for any input!

Scott

eantoranz 01-04-2006 02:48 PM

I think that kind of control is out of "userland" programming. What's gonna be run on each CPU is decided by the kernel, and no other.... I think.

graemef 01-04-2006 03:09 PM

On a dual CPU machine it is the OS that will manage how the load on the CPUs is allocated. So why did you want to have a CPU dedicated to an application?

Would you be able to address this problem by increasing the priority of you application?

Remember; no OS, no memory...

graeme

jlliagre 01-05-2006 01:19 AM

Your custom application will need an O/S to run, you do not "boot" an application, you launch it.
What you may want is to bind that application to the second CPU.
This feature was missed for a long time in Linux, but is now implemented as CPU affinity with kernel 2.5 and 2.6: sched_set_affinity(2).
I'm not sure you can bind the kernel to the first CPU though.

yspm 01-06-2006 07:27 AM

In as much as an "operating system", even the kernel, is an application, anything can run on a CPU. The CPU can access memory without an OS kernel. The kernel simply manages resources between multiple applications that may be running. If it can be guaranteed that only one application will ever run, then no OS is needed. I/O is the bigger challenge, as drivers must be written/adapted that have no kernel coupling. I cannot say much about my application, as it is for a proprietary commercial product.

graemef 01-06-2006 07:35 AM

Okay two cpus one bank of memory chips who gets what? Without cooperation between the two cpu there could be digital anarchy...

jlliagre 01-06-2006 07:55 AM

Quote:

In as much as an "operating system", even the kernel, is an application, anything can run on a CPU.
Not in the widely accepted terminology, where an application is a program running on top of a kernel, while a kernel is one of the kinds of programs directly running on top of hardware (maybe virtual hardware).
Quote:

The CPU can access memory without an OS kernel.
Sure, but this is outside the context of an application running.
Quote:

The kernel simply manages resources between multiple applications that may be running.
This is only part of a kernel role, the kernel handles events that happen without even an application running too.
Quote:

If it can be guaranteed that only one application will ever run, then no OS is needed.
Yes, but you'll have to include in the application most of the services provided by the kernel, which is more than overkill, except for very simple unthreaded applications.
One example of such an application that doesn't run on top of an O/S is grub.
Quote:

I/O is the bigger challenge, as drivers must be written/adapted that have no kernel coupling.
Not only drivers, but file-system access, network stack ...
Quote:

I cannot say much about my application, as it is for a proprietary commercial product.
So it clearly requires an O/S.

graemef 01-06-2006 08:03 AM

Why do you need two CPUs, or is it just a case that you have a machine with two CPUs? I'd have thought that it would be quite easy to buy a second machine and use a network to share the resources that are needed out side of the proprietary commercial product.

jlliagre 01-06-2006 08:39 AM

Just rereading the initial posting:
Quote:

Do you think that canned Linux drivers for PCI and the NIC will be portable to the OS-less application?
No, as the would-be OS-less application doesn't seems to be GPL'd anyway.

yspm 01-09-2006 08:46 AM

So I need to:
1) Remove/replace the kernel-dependent logic from the canned PCI and NIC drivers, or write them from scratch
2) Add an IP stack
3) Make sure I access memory in a way consistent with how the CPU running Linux does

I do not need to do disk I/O, my application deals only with network I/O and memory, and will boot an image provided by the other CPU.

Lots of interesting thoughts have been raised here, but all seem to be solvable problems. The core problem remains though, and the nature of my original questions:
1) how do I make sure only 1 CPU boots, and
2) how do I cause the second CPU to boot an image of my choosing
(Assuming resolution to all the problems raised above)

I am guessing the answer to 1) will have something to do with BIOS, and number 2) to be (hopefully) a capability of Linux.

FYI, the reason for all this is that the 2nd CPU will be running an application which requires EXTREMELY high realtime performance. Calculations show that it will only perform to the needed levels if it has no OS overhead.

graemef 01-09-2006 10:05 AM

I still think that you are going about it in the wrong way. Your approach may be possible but not easy. Whereas installing a CLI only version of linux and your app would mean that your app would have the whole computer minus the small amount of resources that the O/S will use.

You can now focus on tuning the OS, essentially removing the tools that you don't want so that you essentially have just what you require. You can also look at the app and see how to get it to make use of both of the CPUs (maybe adding treads to you application)

I could be wrong but I would have thought that effort in that direction would be far more fruitful.

graeme.

schneidz 01-09-2006 12:19 PM

i agree with the post above. you would essentially be making an embedded linux machine (kinda' like tivo).

even some os-less embedded devices have protocols to handle their own memory management, bus i/o... essentially being an os.

if you want to be totally naked (os-less), i suggest using something like a basic-stamp ii. but you would still be binded by the speed of another pc's serial port. this would lean more towards system programming than software programming.

yspm 01-09-2006 02:47 PM

Dual CPU capabilities of Linux?
 
What capabilities does the Linux kernel provide for controlling the use of a 2nd CPU? Can I launch a thread which will exclusively execute on it? Can anyone point me to an area of kernel documentation that treats the topic of multiple CPU control?

Here is what I need to ensure: that the CPU which runs this application execute a fixed and finite number of instructions to accomplish a well defined task, that will repeat indefinitely. (~700 instructions, 700K times per second)

graemef 01-09-2006 03:11 PM

So you are after about 500 mips which is well within the threshold of most modern CPUs. However getting saying what performance you will get is difficult because we don't know anything about your program. You said it will communicate through the network, will that be a bottle neck, what about VM swapping? Have you got a really good cooling system for your CPU?

You could do worse than try and stress test it, run it with top running that will at least give you an indication of what the load is on your system.

graeme.

yspm 01-10-2006 10:53 AM

I have performed performance tests already, this is how I formed my requirements. I have decided to take my approach, mainly I want to be able to do it myself. There must be things written about it.

So digging further I see that I can boot on 1 CPU by telling GRUB to boot "kernel" rather than "kernel-smp". Now I am faced with learning how to boot the 2nd CPU from an image executing on the 1st. I suppose I can modify a boot loader entry to my purposes. Does anyone know where I can find source code for the boot loader entries to use as a template? Any advice on how to boot the 2nd CPU? Referals to something written on the topic?

Thank you all for the discussion so far, it has heped to clarify things.


All times are GMT -5. The time now is 10:49 PM.