Adding entry to task_struct and initializing to default value - linux-kernel

I want to add an entry to process control block structure (task_struct). Let say a way to tag some process. I want to initialize this field to 0 for all the process except "some special processes", later by calling sched_setscheduler() I will set this flag for the "special processes".
Does anybody have an idea how to assign a default value to a member variable in task_struct?

I'm assuming you are talking about a recent Linux kernel, because implementation detail changes over time.
There are two options. The first - you can set the value of the variable in the init_task global. See how it is done in the linux/init_task.h header. The second option is to add code to copy_process, which you might want to do anyway in order to properly handle the fork() inheritance of the field you are adding.

Related

ODI KM Option - value from FLEX FIELD

Do you think that it's possible to take a value into an ODI IKM Option (for example) from a flexfield?
Example:
You define a flex field on the target table and then pass the value in the IKM.
Then, reading the variable, it's possible to pass it to an option from the IKM?
Thanks,
After searching I found that it's not possible to do it. Conditional Expression can take predefined values. You can find in the next all the combinations:
Condition Expression – It allows you to set the required condition for
the selected option. Double-click the field for editing the condition
expression for the selected option. Click the browse icon Browse icon,
to launch the Edit Expression Editor, which enables you to create or
edit the existing groovy script that determines whether a knowledge
module should be enabled, disabled, displayed or hidden.
Examples are:
return
options.getValue("Cache").equals("true")?"show=true,enable=true":"show=false,enable=false";
This looks at the value of another KM Option called "Cache". If its
value is "false," then the KM Option is hidden, because it's not
relevant.
return
(isStreaming)?"show=false,enable=false":"show=true,enable=true";
This looks at the Mapping isStreaming property. If it's true, then
this option is hidden.
source
It is very easy to do.
You may use odiRef.getTable(java.lang.String pProperty) in the code of your IKM. One of possible values for pProperty is the code of your FlexField.
If you like to pass if through the option just pas <?…?>-substitution as a value of the option. (Probable you should play with %- or ?-substitutions, which is working.)
Refer to «Substitution API Reference» on Oracle site. Many functions like getTable, getIndex, getAK, getContext and others can obtain flexField value of an object of the corresponding type.
Additionally there is the odiRef.getFlexFieldValue() method. It gets the value of any object of any type, but it is required to pass internal IDs as an argument. So it is not convenient.

Reseting "Thread Context"

I would like to know if it is possible to reset the thread context (all of its variables) at the begining of a new iteration.
The problem that I am having is that the thread keeps all the variables (and its values) from its previous iterations and sometimes it things can get messy.
If I am not mistaken, on VisualStudio Performance tests you can specify the percentage of "new users" to indicate how many VirtualUsers are going to have its contexts reseted on their next test iteration.
Do we have something similar native on JMeter or do we need to write some code to do it?
Thanks in advance!
I'm not sure you really want/need it, but you can remove all JMeter variables using JSR223 script with remove method:
for (Map.Entry entry : vars.entrySet()) {
vars.put(entry.getKey(), null);
}
It depends on the type of variables you create and how you use them.
For ex:
Regular Expression Extractor
Here It creates a variable regex.var and if the response matches the expression it will have some value assigned to it. If the next iteration does not match the expression, It will still keep the previous iteration value. To avoid this problem, assign a default value or check the 'Use empty default value'. so that every iteration will basically reset the value.
User Designed Variables - Each and every thread will have its own copy of the variable and threads could be modifying its variable value throughout the entire duration of the test. If you want that to be reset for every iteration, it is completely your responsibility.
I think this could be helpful.
JMeter - Understanding Variables Scope

UiPath: Collection.contains("string") doesn't appear to be returning Boolean as expected

First I use a "Get processes" activity which assigns its result to a variable called currentProcessesCollection which is of type Collection
Next I want to check this condition in and If activity currentProcessesCollection.Contains("OUTLOOK")
I'm getting 'string' cannot be converted to type System.Diagnostics.Process'
I'm kind of flummoxed by this and wondering if anyone knows some other way to do this. I was kind of hoping that writing out the problem would help, it didn't. Thanks for any help in advance. I need to find out if outlook is running.
As you correctly said, currentProcessCollection contains a collection of Process objects. As such, Contains requires another Process object in order to compare them, when you provided the string object "OUTLOOK.EXE".
If you want to search whether at least one process by name exists, just assign the following to a boolean variable (just replace Scan with any process name):
processCollection.Where(Function(x) x.ProcessName = "Scan").Count > 0

Assign a string value as a result of a command

I want to put a string result of a command in WinDbg in a variable for a later use.
For example, in a memory breakpointI want to save the result of - lm1ma eip that returns me the current module, for later comparison in $spat command.
If anyone knows a better way to achieve the goal of determining if the current debugged module is a specific module, inside a conditional breakpoint, it could be also helpful.
Use as /c Name CommandString.
It creates an alias to the results of executing the specified command.
https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/as--as--set-alias-

Xcode 3.2 Debug: Seeing whats in an array?

Whilst debugging in Xcode_3.1.2 I am pretty sure I could see the contents of my NSString arrays. However after upgrading to 3.2 I only see the following ...
I know I can print the object in (gdb) using "po planetArray" or simply click in the debugger and "print description to console" I am just curious, as I am sure it worked prior to upgrading. Anyone know anything about this?
cheers gary
edit: data formatters is on and it shows what you see above ...
This is because GDB acts as if the variable you are viewing is out of scope while it really just is confused about what each part function or method call of the data formatter is returning (the data formatter is the "{(unichar *)Xcode_CFStringSummary($VAR, $ID)}:s" part you are seeing.
When you are debugging and you are in a method where you know a local variable must be in scope right now, open the debugger window and the area where you can see "Variable", "Value" and "Summary" column titles double click the "Summary" row entry for the variable you are interested in and enter the following (for array types like NSArray or NSCFArray):
"{(int)[$VAR count]} objects {(NSString *)[(NSArray *)$VAR description]}:s"
then press return. You have now overwritten the default data formatter provided by Xcode's GDB extension (to be found in various plists at "/Developer/Library/Xcode/CustomDataViews/") with your own data formatter string.
Your own overrides are saved at "~/Library/Application Support/Developer/Shared/Xcode/CustomDataViews/CustomDataViews.plist" and if you want to have the Apple default data formatter back just double click the row for a variable of the same type and delete whatever is there.
The nitty-gritty details: In the custom expression above the "{}" construct tells GDB to execute a command (as if you where executing it from GDB's debugger command line, which means the same restrictions apply: you need to specify the return type in cast parens in front of every function or method which returns something). The ":s" behind the closing curly brace tells Xcode and GDB to reference the "Summary" column. Also valid would be ":v" which references the "Value" column which most of the time is just the pointer value. Everything that is outside of the curly braces is shown verbatim.
Unfortuntely curly braces can't be nested which invalidates ternary operator conditionals.
So with the above data formatter you should see the following for an empty NSArray:
"0 objects (\n)"
If you want to write your own data formatters as GDB extensions (equivalent to specifying a function akin to Xcode_CFStringSummary above) you can do so. Take a look at the following header: "/Developer/Applications/Xcode.app/Contents/PlugIns/GDBMIDebugging.xcplugin/Contents/Headers/DataFormatterPlugin.h"
it will tell you all you need to know. But it can be hard to get it right. It might be easier and less error prone to just define another method on your class and call that from the data formatter string instead of "description".
In the Run > Variables View menu in Xcode, is "Use Data Formatters" enabled?
I am not sure if this helps but if you select the array value to wish to see in the debugger window and the go to the Menu : Run > Variables View > View Variable As
you can change it from "NSCFString *" to "NSString *". You then see the value so "Planet_1" for example.
Cheers,
Kevin

Resources