LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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-18-2010, 01:52 PM   #1
bahhti
LQ Newbie
 
Registered: Nov 2009
Posts: 12

Rep: Reputation: 0
is system call scheduling possible?


i have written a sytem call. and i want to it to be called between certain intervals. how can i do this??
thanks in advance
 
Old 01-18-2010, 02:18 PM   #2
lwasserm
Member
 
Registered: Mar 2008
Location: Baltimore Md
Distribution: ubuntu
Posts: 184

Rep: Reputation: 41
"system call" has a certain meaning with respect to computer programming, especially in unix/linux systems, that makes your request somewhat puzzling. Perhaps you wrote a script or program that you want called at certain times? If so then you can put it in a cron job.
 
Old 01-18-2010, 02:33 PM   #3
bahhti
LQ Newbie
 
Registered: Nov 2009
Posts: 12

Original Poster
Rep: Reputation: 0
in fact i dont know much about kernel programming. but i have written a system call that need to be called say every 60 seconds. maybe i can call this syscall from a thread or a process, in a while loop sleep 60 secs and call it repeatedly. but this thread or process should be created after another system call that i will define. if that is not okay this process run everytime and tests a flag which can be set by the sytem call if it is called. this are some things coming to my mind but as i have little knowledge, i neither know how to implement, nor am sure they are applicable.
 
Old 01-18-2010, 02:44 PM   #4
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Rep: Reputation: 22
A system call is an interrupt. The CPU(s) that are allowed to handle that INT (surely only one, the system CPU) can't execute any other things until return so the scheduler seams to be halted.
But if you want to execute your INT every schedule cycle than simple call that INT from a user space thread (pthread.h) in a loop:
Code:
bool RUN = TRUE;
bool WAIT = TRUE;

do {
  <syscall>
    while( WAIT ) ;
      
     WAIT = TRUE;
} while( RUN );
In an other thread you set WAIT to false in such a loop then your INT is only called once each time.
Like this you can execute your app. and your INT is called every schedule cycle.

If this is not enough then you have to describe your problem and what you want to do.
 
Old 01-18-2010, 06:03 PM   #5
bahhti
LQ Newbie
 
Registered: Nov 2009
Posts: 12

Original Poster
Rep: Reputation: 0
i think it will be nice if i explain what i am trying to do. i have an assignment, i need to limit the file read operations. the limit will be set by a sytem call which takes one parameter(limit) and will be accesible only by root. so i have declared a global variable and written a sytem call which can set it. but this limit is also per minute. i mean if the limiting system call is passed 1024 then max file system usage will be 1024kn/minute. so i want to call this system call(which sets the variable) every minute and set it to 1024. and i will use this variable in sys_read() to control reading operations. is this way sensible , or should i follow something different? if ok how can i manage to call the syscall every onece per minute.
thanks
 
Old 01-19-2010, 12:31 PM   #6
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Rep: Reputation: 22
Quote:
Originally Posted by bahhti View Post
but this limit is also per minute. i mean if the limiting system call is passed 1024 then max file system usage will be 1024kn/minute. so i want to call this system call(which sets the variable) every minute and set it to 1024. and i will use this variable in sys_read() to control reading operations.
It seams a little confusing.
Do you want to limit the bytes that are read by a process, at all, device or a file opened?

If you want to limit the data transfer then this is right pretty done in the terminal device or any other serial device. Have a look on tty and terminal emulation (VT 100 ...).

maybe you want to read a little about streaming and buffers ?

If you want to limit the bytes read by sys_read() per minute then I think a kernel parameter is the right choice in /proc/sys/kernel. In sys_open() the parameter could be set and manipulated by user app. and sys_read() uses it also a minute process is created (sys_sleep()). If that parameter is not 0 then that process is active and sleeps for a minute and if awake it clears the sys_read() variable bytes_read. Like this sys_read() can compare the limit with the value bytes_read and stop further readings.

If you only want to limit the calls of the sys_read() function then also set a minute process and sys_read() counts and compares its calls and the minute process clears that variable. Think about an error code to implement that apps. wanted to read something give you back the right error (f.e. reading not possible, error was: "To many readings per minute")

bastl
 
  


Reply



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
OSE system call functions to Linux Sytem Call functions required roshantraj30 Linux - General 0 06-08-2009 02:06 AM
How to call system call from usb driver's code Mr.J Linux - Kernel 4 09-29-2008 03:47 AM
How can i make centos 4.5's system call using vDSO(call *%gs:0x10) instead of int80 tclwp Red Hat 3 08-06-2007 12:07 AM
Calling a system call from a system call? Loc_8 Programming 0 09-16-2006 04:21 PM
Workflow management and scheduling system compghod Linux - Software 1 07-10-2006 06:32 AM

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

All times are GMT -5. The time now is 01:12 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