Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux Hosts
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > Linux Programming & Scripting
Reload this Page User-space application running
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Linux Programming & Scripting C, Perl, PHP, Bash Scripts, anything programming or script related post in here!

Reply
 
Thread Tools Display Modes
Old 07-20-2008   #1 (permalink)
limp
Just Joined!
 
Join Date: Jul 2008
Posts: 6
User-space application running

Hello to all!
I am a new Linux user and I would really appreciate any help you can provide me in order to clarify some things regarding application running in Linux.

I have successfully compiled the below Hello World program:

Code:
#include <stdio.h>

int main() 
{
printf("Hello world!\n");

return 0;
}
and I got an executable named "hello.out"

When I am running the application by typing into bash:
Code:
$./hello.out
I am getting the "Hello world" message however I have a few questions regarding the involve of kernel scheduler to this application execution.

1) In this case I am running a function from user space without using any of the scheduler routines in order to e.g. add the task to scheduler "run queue" list or to specify the priority of this execution so I can't understand how the scheduler is invoked to the execution of the program without using any of the scheduler's routines in order to provide information about this execution. (how the scheduler knows about the existence of this application?)

What's the process in order finally the task to be executed?

2) How can I have a periodic execution of the application?

3) What's the priority of this execution? Is there a way to see all the applications that kernel scheduler runs and how often?

4) If I was running two applications, which one would be running first? Could I change the priority of its execution somehow?

Any help would be really appreciated.
Thank you!
limp is offline   Reply With Quote
Old 07-20-2008   #2 (permalink)
GNU-Fan
Linux Newbie
 
Join Date: Mar 2008
Posts: 133
Hello,

Quote:
Originally Posted by limp View Post
1) In this case I am running a function from user space without using any of the scheduler routines
You tell your shell interpreter (bash?) to do this for you.
I assume the shell uses any of the execl runtime functions which in turn
load the binary into ram and tell the kernel about it.

Kompf.de - POSIX Library Functions
Runtime library - Wikipedia, the free encyclopedia



Quote:
Originally Posted by limp View Post
2) How can I have a periodic execution of the application?
Most easily via a shell script which executes the application periodically.
Linux Shell Scripting Tutorial - A Beginner's handbook

Quote:
Originally Posted by limp View Post
3) What's the priority of this execution? Is there a way to see all the applications that kernel scheduler runs and how often?
You mean the 'top' and 'ps -aux'?

Quote:
Originally Posted by limp View Post
4) If I was running two applications, which one would be running first?
Could I change the priority of its execution somehow?
Isn't Linux a multitasking kernel?
You might want to look into 'nice'. (not the French town but the command/function)
GNU-Fan is offline   Reply With Quote
Old 07-21-2008   #3 (permalink)
limp
Just Joined!
 
Join Date: Jul 2008
Posts: 6
You preety much solved all of my problems! Thank you!

However, I am trying to have a little bit diper understanding of how the bash communicates with the scheduler in order the latest to execute the application.

There should be some specific system calls I suppose.

I searched for the "./" command that I use in bash in order to execute an application but I didn't found any information related with it.

Thanks again!
limp is offline   Reply With Quote
Old 07-21-2008   #4 (permalink)
GNU-Fan
Linux Newbie
 
Join Date: Mar 2008
Posts: 133
Lol,
the './' is no command. It refers to the current directory.

This is due to how command line extension works:
When you type in a command, say 'ls', the bash tries to find it in any of the directories that are listed in the 'PATH' environment variable.
(Type 'echo $PATH' to see its content.)

On my system it says:
/usr/local/bin:/usr/bin:/bin:

This means, when I start 'ls', the shell checks whether there is an executable "/usr/local/bin/ls".

If not, the next path is tried:
"/usr/bin/ls" etc.

Because the default setting is to ignore files in the current directory (for security reasons), you have to explicitly state that you want Bash to execute the file in the directory you are now. (The dot is a shortcut for "current directory", the ~ is a shortcut for your home directory)
GNU-Fan is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 04:52 AM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.0.0