LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-03-2006, 10:50 AM   #1
yspm
LQ Newbie
 
Registered: Jan 2006
Location: DC Metro
Posts: 12

Rep: Reputation: 0
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
 
Old 01-04-2006, 02:48 PM   #2
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
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.
 
Old 01-04-2006, 03:09 PM   #3
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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
 
Old 01-05-2006, 01:19 AM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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.
 
Old 01-06-2006, 07:27 AM   #5
yspm
LQ Newbie
 
Registered: Jan 2006
Location: DC Metro
Posts: 12

Original Poster
Rep: Reputation: 0
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.
 
Old 01-06-2006, 07:35 AM   #6
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Okay two cpus one bank of memory chips who gets what? Without cooperation between the two cpu there could be digital anarchy...
 
Old 01-06-2006, 07:55 AM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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.
 
Old 01-06-2006, 08:03 AM   #8
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 01-06-2006, 08:39 AM   #9
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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.
 
Old 01-09-2006, 08:46 AM   #10
yspm
LQ Newbie
 
Registered: Jan 2006
Location: DC Metro
Posts: 12

Original Poster
Rep: Reputation: 0
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.
 
Old 01-09-2006, 10:05 AM   #11
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 01-09-2006, 12:19 PM   #12
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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.
 
Old 01-09-2006, 02:47 PM   #13
yspm
LQ Newbie
 
Registered: Jan 2006
Location: DC Metro
Posts: 12

Original Poster
Rep: Reputation: 0
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)
 
Old 01-09-2006, 03:11 PM   #14
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 01-10-2006, 10:53 AM   #15
yspm
LQ Newbie
 
Registered: Jan 2006
Location: DC Metro
Posts: 12

Original Poster
Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Linux Application Modify I/O and Inter-CPU connections? xyzxyz Linux - Hardware 0 11-02-2005 09:43 AM
Custom Gnome keymap on a per-application basis? darthspacey Linux - Software 0 05-23-2005 01:35 PM
Custom boot disc mikedeatworld Linux - Software 11 09-07-2004 08:38 AM
Issues running a custom application schapmn1974 Linux - Software 3 07-12-2004 06:42 AM
Custom Kernel Won't Boot!?!?1 martinman Linux - General 1 07-12-2003 01:10 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration