getpriority() function in linux - linux-kernel

may i know the exact usage of getpriority() call used in linux.. even after searching thru net, i couldnt understand it exactly.. can someone explain it with an example.. thnx in advance :)

The scheduling priority of the process, process group, or user, as
indicated by which and who is obtained with the getpriority call ...
So, it returns a priority. It takes two args.
The first arg tells it how to interpret the second arg.
which is ... one of PRIO_PROCESS,
PRIO_PGRP, or PRIO_USER,
So, if which is PRIO_PROCESS, then 'who' is a process id, if it is PRIO_PGRP, it is a
process group id, and if it is PRIO_USER, it is a user ID. A zero of who means the caller.
In the second two cases, the result is to select a set of processes, so it returns the lowest priority number of all of the selected processes.

Related

Webi: On opening, filter data by current user name which can be in or not in a given list (no prompt)

(SAP BusinessObjects BI Platform 4.3 Support Pack 1 Patch 11 Version : 14.3.1.4142.11)
Disclosure: I'm not born english speaking, but if I have understood correctly, we should now use "they", instead of he/she, etc. That is what I did here. Just to be sure no one is confused while reading.
Hi everyone, it's me again for a webi question.
I have this report in which I have data for a group of workers. These data are: their name, when they work, where, which activity they do, etc.
Worker name
Other information
Worker A
...
Worker B
...
...
...
Worker M
...
Worker Z for example is not in the list.
I currently have a filter "name" (multi-list), which allows us to select one or more workers (Worker A, Worker B,...). By default, it shows all data.
There is an auto-refresh on opening.
The function CurrentUser() returns the worker ID, not the name.
Worker name
Worker ID
Worker A
238x01f93
Worker B
4j192h60a
...
...
Worker Z
09ad812jn
I have two kind of user, that can see this report:
A user whose name is present in the list of workers (e.g. Worker A).
A user whose name is not present in the list of workers (e.g. Worker Z).
My goal:
When the user opens the report, the filter "name" is set by default with their name (e.g. Worker A). This way, they see only their data. If they want to see the data of other workers, they can easily change the filter to select other workers (e.g. Worker B and C). It should not be limited.
When the user (Worker Z) opens the report, they see all data. They can naturally use the filter to select only one or a few workers if they want to.
What I did/tried:
I can change things in the view (database), in the universe or/and in the report. I only tried things on the report level, because I could not see any ways to help me solve this on universe or view level. (But I am open to suggestions! :-) )
Create a variable to:
Filter for only current user ID. It worked, but only if the user name was in the list. Another problem is that the workers don't know this user ID and can't work with it.
=CurrentUser()
Search in the list, if the current user ID exists. Does not work. It shows always all data.
If (Pos([Personalnumber];CurrentUser()) > 0) Then CurrentUser() Else [Personalnumber]
Link the current worker ID with their name if they are in the list. It worked well for them, but I could not find a way to have all workers, if the current user name is not in the list.
If (CurrentUser() = [Personalnumber]) Then [Name] Else "All"
I read so many posts, but none for my case. It is often to prevent user to see all the data, which is not what I want. They should be able to see everything, if they want to.
We only want to filter for the current user for performance means and also efficiency. The user does not have to select themselves the right filter and loose time. Most of the time, they only wants to see their data.
Can anyone help me?
Don't hesitate to tell me if something is unclear or missing. :-)
Thanks for your time!

Power Automate Get Planner Task Assignee Names

I'm working on a Power Automate flow where the flow is supposed to connect to Planner, get the tasks which are due tomorrow and send a message to an MS Teams Channel.
I got the entire flow working except of one thing - getting the names of the person(s) whom the task is assigned.
Here's my current flow:
Getting the list of Tasks from Planner,
Filter those which have a Due Date set,
Filter the ones which have the Due Date tomorrow,
Get the Name of the Task Creator using Get User Profile,
Send the data into an MS Teams Channel.
This all works perfectly fine. However I also need to get the names of the Assigned users. I understand that they come as an array. And when I try to add it to the same Get User Profile it's getting wrapped into an unnecessary "Apply to Each" which breaks everything.
Does anyone have a clue how this can be solved? Basically I need only 1 Assignee as we are not going to assign the same task to more than 1 person.
Any help would be much appreciated!
In order to avoid the loop (which is also a valid approach, long story) then you can use an expression to get the first (in case there are multiple) assigned user.
This is an example where you don't need to loop ...
... you can see I've initialised a (string) variable at the top which will hold the user ID GUID.
... then further down in the Set Assigned To operation, this is the expression I use ...
item()?['_assignments'][0]['userid']
That gets the first user and then the associated userid property. You can then pass that into the Get user profile (V2) task ...
Obviously, you need to adapt that to your flow but I hope that makes sense.

Creating a simple scheduler

How would I go about creating a simple Scheduler that say, delays every item by a second? I want to use it for an Observable, and yes, I know that can be done in multiple other ways, I jsut want to accomplish it using a custom Scheduler.
There's some related tutorial here: http://codebetter.com/matthewpodwysocki/2010/05/12/introduction-to-the-reactive-extensions-for-javascript-custom-schedulers/ but it is quite outdated and the API looks very different now.
The current docs are not very usefuleither, but I guess I should be using Rx.Scheduler.prototype.schedulePeriodic, although I don't know what the action parameter should be.
To create a new scheduler from the base scheduler you should have a look at scheduler.js. Essentially you need to understand how to do 4 things and you will automatically get all the periodic, recursive, exception handling extensions for free.
The function signature of Scheduler is
function Scheduler(now, schedule, scheduleRelative, scheduleAbsolute){}
To break it down:
now - A function that represents the schedulers notion of time, at any point when this is called it should return what the scheduler thinks now is. The default is to simply return new Date()
schedule - A function called when the action should be executed as soon as possible This function has the signature
function scheduleNow(state, action) {}
where action will have the signature
function action(scheduler, state) {}
It is used to schedule immediate actions on the scheduler. Immediate will have different meanings depending on your scheduler, however, for most cases (immediateScheduler aside) you will want that to occur in the next tick, whatever that means to your scheduler. You can have a look at the defaultScheduler, which does a little work to figure out what the best method would be in the environment (setImmediate is the first choice). In your case, since immediate will really mean "one second from now", you could probably just route it to scheduleRelative with this.scheduleRelativeWithState(state, 1000, action)
scheduleRelative This is called when the action should occur sometime in the future relative to now:
function scheduleRelative(state, dueTime, action) {}
Again this will likely use setTimeout with dueTime as the time parameter.
scheduleAbsolute This is probably the easiest to implement, it has the same signature as scheduleRelative, however instead of taking a time relative to now it is taking an absolute time irrespective of now (usually a Date object), to convert it you really just need to subtract now from it and pass it into this.scheduleWithRelativeAndState (see I told you you'll get free stuff).
In all cases the 3 schedule methods return a Disposable, this is used for best effort cancellation of the action. In the case of setTimeout this would be clearing the timeout using the returned id.
To finally answer your question, if you wanted to delay everything by 1 second the best way will probably be to apply a shift in scheduleRelative adding 1 second/1000 milliseconds to each scheduled event.

Delphi - delay processing if user still typing

I have an application which has an Edit Field. The user will type a search phrase in this field. I am trying to show in real time the hits against the user's text. After entering three characters, I do my first search, and then after every character or backspace the search is performed again.
The problem is that as my search algorithm is getting more advanced, it takes longer to do the search. The user can type faster than the results are before generated/displayed. As a result, the app is feeling sluggish/slow. I have a couple options:
(1). Wait until the user hits enter (2). Put the search in a different thread and do it asynchronously. Kinda hesitant here since I have never worked with threads before (3). Implement some type of delay so that if the user is still typing, I wait for the user to stop.
I am leaning towards option 3, but how do I detect if the user is still typing? Do I have to keep a timestamp associated with every keystroke?
If I were you I would stick with the threading solution.
It is faster, does not lag and - if written properly - will not introduce additional problems, and is a great opportunity to learn threading by a not so risky or difficult problem. If you choose this solution you will have to perform four easy steps:
Create an OnSearchFinished() event handler on your form and assign it to a message code (like WM_USER + 1). This message will be sent by your thread when it has finished producing search results.
Create a TThread descendant with your search code in its .Execute() method that will perform the search. It has to have a field with the search term. (The .Execute() will not be called directly so it can't handle parameters. You execute TThread descendents by .Resume()ing them.) The instance of this class can be created in the constructor of your form and needs to be created in suspended state.
Assuming your search code has a main cycle, you will have to check if your main program called .Terminate() over your object. If it has, you have to exit your cycle.
In the .OnChange() or .OnKeyDown() where you handle your search, you should (first) .Terminate() your thread (to stop an already running search if there is any), then set the field to your new search term and .Resume() it.

Is there a better way to store one incremented Integer in a db in a thread safe way than blocking?

I'm developing a Sinatra app which uses unicorn. Each worker is one thread, it loads the whole application, they just share the db. (please correct my if I'm wrong ;) )
The first thread gets the Integer, does something with it and then increments it, the second thread should not get the Integer of the first thread (thread safety), it should only get the incremented Integer.
I did that with blocking, but want to find a better approach because during my research I often read that this is a very bad way of solving my problem as it's not very scaleable.
If you want to see my whole application feel free to check it out on github ;)
Seems that you're trying to generate alphanumeric ids for shortened urls. If this is the case, then it's much simpler than you think
Let there be a regular auto-incrementing id integer field. When a new request comes in, you create a record in the database, get its id (which won't be repeated again and other workers won't get it), convert it to an alphanumeric form and save (to another column).
Ruby even includes conversion methods for some cases.
aid = 1746563
s = aid.to_s(36) # => "11fnn"
i = s.to_i(36) # => 1746563
You can just use your methods instead of these.
Update
Since you mentioned that you use Posgresql, there is a perfect tool for this: Sequences!
You can create a sequence and then get auto-incrementing numbers from it, without worrying that another client will get the same value.

Resources