public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] high priority task as user (nice/ionice)
@ 2009-08-23  8:20 meino.cramer
  2009-08-23 14:05 ` Mike Kazantsev
  0 siblings, 1 reply; 6+ messages in thread
From: meino.cramer @ 2009-08-23  8:20 UTC (permalink / raw
  To: Gentoo


Hi,

with guvcview I capture video streams of some birds, which
sometime arrive on the roof.
When they do I press the record button of the guvcview application.

The webcam I use is able to deliver 30fps at 640x320 pixel with audio 
via usb.
Unfortunately while recording nothing else should use the CPU/the IO
system heavily otherwise I will get an vi-vi-ddd-d----d-deooo-o--o-o
(stuttering performance).

In this list I read about ionice and nice, which latter I know before.
Form the manpages of both I read, that only root is allowed to give
process higher priority than normal.
I want to give guvcview high IO- and CPU-priority without the hassle
to pickup PIDs and lunch nice/ionice by root-hand after the start of 
guvcview (user-process).

And I am iusing icewm (no KDE/GNOME as desktop)

Is there any chance to start guvcview with user rights AND to give the
application higer priorities so that whatever guvcview wants from the
system will be served as soon as possible to avoid stuttering videos?

Thank you very much in advance for any help!

Have a nice sunday!
mcc

-- 
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] high priority task as user (nice/ionice)
  2009-08-23  8:20 [gentoo-user] high priority task as user (nice/ionice) meino.cramer
@ 2009-08-23 14:05 ` Mike Kazantsev
  2009-08-23 14:19   ` meino.cramer
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Kazantsev @ 2009-08-23 14:05 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

On Sun, 23 Aug 2009 10:20:08 +0200
meino.cramer@gmx.de wrote:

> Is there any chance to start guvcview with user rights AND to give the
> application higer priorities so that whatever guvcview wants from the
> system will be served as soon as possible to avoid stuttering videos?

You can create a simple script, say, /usr/local/bin/capture and give
permissions to lauch it as root via sudo.

Script might be one-liner like

  #!/bin/sh
  exec nice -n -10 ionice -c 1 capture-command

and sudo line might look like this:

  user ALL=(root) NOPASSWD: /usr/local/bin/capture

NOPASSWD here means that you just have to type
'sudo /usr/local/bin/capture' to run the script as root, no questions
asked.

-- 
Mike Kazantsev // fraggod.net

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] high priority task as user (nice/ionice)
  2009-08-23 14:05 ` Mike Kazantsev
@ 2009-08-23 14:19   ` meino.cramer
  2009-08-23 14:29     ` Stroller
  2009-08-23 15:05     ` Mike Kazantsev
  0 siblings, 2 replies; 6+ messages in thread
From: meino.cramer @ 2009-08-23 14:19 UTC (permalink / raw
  To: gentoo-user

Mike Kazantsev <mk.fraggod@gmail.com> [09-08-23 16:08]:
> On Sun, 23 Aug 2009 10:20:08 +0200
> meino.cramer@gmx.de wrote:
> 
> > Is there any chance to start guvcview with user rights AND to give the
> > application higer priorities so that whatever guvcview wants from the
> > system will be served as soon as possible to avoid stuttering videos?
> 
> You can create a simple script, say, /usr/local/bin/capture and give
> permissions to lauch it as root via sudo.
> 
> Script might be one-liner like
> 
>   #!/bin/sh
>   exec nice -n -10 ionice -c 1 capture-command
> 
> and sudo line might look like this:
> 
>   user ALL=(root) NOPASSWD: /usr/local/bin/capture
> 
> NOPASSWD here means that you just have to type
> 'sudo /usr/local/bin/capture' to run the script as root, no questions
> asked.
> 
> -- 
> Mike Kazantsev // fraggod.net

This will give the whole 'capture-comand# the rights of root, which
I want to prevent (see my posting). Instead I want to give it only
higher priorities for I/O-usage and CPU-usage. It should still act
with user rights for all other puposes.
But thank you for your help anyway.

Best regards.
mcc



-- 
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] high priority task as user (nice/ionice)
  2009-08-23 14:19   ` meino.cramer
@ 2009-08-23 14:29     ` Stroller
  2009-08-23 15:05     ` Mike Kazantsev
  1 sibling, 0 replies; 6+ messages in thread
From: Stroller @ 2009-08-23 14:29 UTC (permalink / raw
  To: gentoo-user


On 23 Aug 2009, at 15:19, meino.cramer@gmx.de wrote:
>> ...
>>  #!/bin/sh
>>  exec nice -n -10 ionice -c 1 capture-command
> ...
> This will give the whole 'capture-comand# the rights of root, which
> I want to prevent (see my posting). Instead I want to give it only
> higher priorities for I/O-usage and CPU-usage. It should still act
> with user rights for all other puposes.

Use renice / snice. No idea if ionice has an equivalent.

http://www.google.com/search?q=nice+existing+process
http://www.forwardyouth.com/ubuntu/set-the-nice-level-of-an-existing-process/
http://www.nixtutor.com/linux/changing-priority-on-linux-processes/

Stroller.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] high priority task as user (nice/ionice)
  2009-08-23 14:19   ` meino.cramer
  2009-08-23 14:29     ` Stroller
@ 2009-08-23 15:05     ` Mike Kazantsev
  2009-08-23 15:19       ` meino.cramer
  1 sibling, 1 reply; 6+ messages in thread
From: Mike Kazantsev @ 2009-08-23 15:05 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 573 bytes --]

On Sun, 23 Aug 2009 16:19:14 +0200
meino.cramer@gmx.de wrote:

> This will give the whole 'capture-comand# the rights of root, which
> I want to prevent (see my posting). Instead I want to give it only
> higher priorities for I/O-usage and CPU-usage. It should still act
> with user rights for all other puposes.
> But thank you for your help anyway.

Ah, sorry, must've missed that part.
How about this:

  #!/bin/sh
  exec nice -n -10 ionice -c 1 sudo -u user capture-command

(with the same initial sudo-invocation)

-- 
Mike Kazantsev // fraggod.net

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] high priority task as user (nice/ionice)
  2009-08-23 15:05     ` Mike Kazantsev
@ 2009-08-23 15:19       ` meino.cramer
  0 siblings, 0 replies; 6+ messages in thread
From: meino.cramer @ 2009-08-23 15:19 UTC (permalink / raw
  To: gentoo-user

Mike Kazantsev <mk.fraggod@gmail.com> [09-08-23 17:08]:
>   #!/bin/sh
>   exec nice -n -10 ionice -c 1 sudo -u user capture-command
> 
> (with the same initial sudo-invocation)
> 
> -- 
> Mike Kazantsev // fraggod.net


...starts the capture command with user-rights, nice and ionice
fail cause starte with user rights,

Found the soultion myself in the meanwhile:

--------------------------------------------------------
#! /bin/sh
guvcview &
pID=$!
sudo ionice -c 1 -p ${pID}
sudo renice -10 -p ${pID}
--------------------------------------------------------

...starts guvcview with user rights and renice/ionice it
to higher levels with short running root priviledged 
commands...

mcc

-- 
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-08-23 15:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-23  8:20 [gentoo-user] high priority task as user (nice/ionice) meino.cramer
2009-08-23 14:05 ` Mike Kazantsev
2009-08-23 14:19   ` meino.cramer
2009-08-23 14:29     ` Stroller
2009-08-23 15:05     ` Mike Kazantsev
2009-08-23 15:19       ` meino.cramer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox