Same name among FreeRTOS tasks - task

I'm a newbie of FreeRTOS. But I don't think it's well documented. As in xTaskCreate() :
pcName A descriptive name for the task. This is mainly used to facilitate debugging, but can also be used to obtain a task handle.
The maximum length of a task’s name is set using the configMAX_TASK_NAME_LEN parameter in FreeRTOSConfig.h.
Is a task must be associated with a name?
What happened if pcName is NULL?
What happened if I created multiple tasks with the same name?
Should I maintain the mapping between task's handle and name? Or FreeRTOS maintains this relation?
In a word, it's not clear about the relation of task's handle and it's name in official document.

No it does not need a name
If pcName is NULL it simply does not have a name. Nothing happens.
You will get several tasks with the same name so you cannot identify them by name. The behaviour of xTaskGetHandle is then undefined (as per the documentation).
FreeRTOS handles this.
The documentation also states this function takes a long time to complete and should be used sparingly. Personally I don't think there is any reason to use this at all. Just use task names for debug purposes only (useful in a debugger or when using Percipio Trace)

Related

AWS CDK Get Pinpoint Project/Application ID

In the AWS CDK, it's straight forward to create a Pinpoint Service. But how do you get the Project ID (also referred to as the Pinpoint App ID or Application ID) for use in subsequent CDK code.
Create a Pinpoint project:
const pinpointProject = new pinpoint.CfnApp(this, 'PinpointNotificationProject', {
name: 'myProject',
});
In the AWS CloudFormation docs it says:
"When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the unique identifier (ApplicationId) for the Amazon Pinpoint application."
However, the following CDK code returns the project name not the id. The value of logicalId = myProject.
cdk.Fn.ref(pinpointProject.logicalId); // This returns 'myProject'
pinpointProject.ref; // This also returns 'myProject'
This is confirmed fixed in the latest CDK version 1.130.0. The ref property now returns the Pinpoint ProjectId.
The problem you are running into is that pinpoint is not a finished module. You can see this that all the functions within are prefixed with Cfn - cloudformation. This means that they are barebones and not tied into all the interface hooks that the rest of CDK is making use of to toss things around.
First, the logical ID is NOT the project name. the Logical Id is part of the Cloudformation Template that is generated for any resource Cloudformation is going to stand up. It links the given resource to the stack, so that any changes under the same logical id will be applied to the same stood up resource. It is only referenced internally to the cloudformation stack and never known outside. CDK uses the LogicalID to generate the name of the resource if you do not specify one.
Second, Taking a look at the documentation shows that CfnApp has the following property: attrArn. Meaning in your code, you would reference this by pinpointProject.attrArn - the arn of a pinpoint resource is something like: arn:aws:mobiletargeting:region:accountId:apps/projectId. with, as you guessed it, the projectId as the last value. you can split the string and get that value out, or use the arn manipulation methods provided as part of the core module to extract what you need.
Finally, even though the Pinpoint module is pretty much just barebones, it may still be possible to pass the variable storing your Pinpoint Construct Object to whatever other resource requires it. I say may because, as mentioned, most of the Cfn prefixed functions do not have the proper hooks to do this well - but some do, and Ive never worked with Pinpoint directly.
I recommend spending some time to understand how the CDK Documentation is laid out. Its bare bones in places, but once you understand how they structured it, these kinds of questions are readily answered within.

How do i get current processor id in macOS KEXT

I found kern/processor.h files that include current_processor().
But I cannot use current_processor() even i include kern/processor.h file.
Is there any methods to get current processor id?
Add 030420 : I need any methods that get current processor id and methods should be possible to used in KEXT. current_processor(), cpu_number() doesn't work on KEXT.
The following function is declared in <kern/cpu_number.h>:
extern int cpu_number(void);
and returns the index of the CPU on which the code is currently executing.
Please note that this is in the unsupported KPI however, so you need to link against com.apple.kpi.unsupported.
Also note that the result will be meaningless unless preemption is disabled, which is of course normally not the case, only when a spinlock is held, or when running in a primary interrupt handler. Preemption being enabled means that the running thread can be rescheduled at any time, so by the time your code uses the CPU number it obtained by calling the above function, it may already have been rescheduled to run on a different CPU.

Dask - Possible to assign dask_key_name to dask dataframe tasks?

In the course of debugging issues, I've found it hard to decipher exactly which tasks are causing problems. I've used the 'dask_key_name' kwarg successfully in delayed tasks to assign a human-readable name to the key for those delayed tasks (based on the documentation here: https://docs.dask.org/en/latest/delayed-api.html). I've tried to do the following in the hopes that it would do the same for the read_parquet tasks, but it appears it still uses a hashed value to create the key (e.g., ('read-parquet-ed9e6c4c474e851e176e7eafb8753490', 5)).
item = 'custom_string'
self.all_pfs_dict['read'][item] = dd.read_parquet(item_to_read, index=False, gather_statistics=False, dask_key_name=item + '-read')
Am I doing something wrong or is there an alternative way to name dask dataframe tasks?
There is no way to rename dataframe tasks like this today.
I have previously had a similar question, but it does not seem to support such a thing except from_pandas() method.
from_pandas() has the name parameter to set name, but others like read_parquet() don't.
So if you want to do it, you need to change the Dask code linked above.

Dataflow/Beam Templates, Productionization, Initialization, and ValueProviders

I have an Apache Beam job running on Google Cloud Dataflow, and as part of its initialization it needs to run some basic sanity/availability checks on services, pub/sub subscriptions, GCS blobs, etc. It's a streaming pipeline intended to run ad infinitum that processes hundreds of thousands of pub/sub messages.
Currently it needs a whole heap of required, variable parameters: which Google Cloud project it needs to run in, which bucket and directory prefix it's going to be storing files in, which pub/sub subscriptions it needs to read from, and so on. It does some work with these parameters before pipeline.run is called - validation, string splitting, and the like. In its current form in order to start a job we've been passing these parameters to to a PipelineOptionsFactory and issuing a new compile every single time, but it seems like there should be a better way. I've set up the parameters to be ValueProvider objects, but because they're being called outside of pipeline.run, Maven complains at compile time that ValueProvider.get() is being called outside of a runtime context (which, yes, it is.)
I've tried using NestedValueProviders as in the Google "Creating Templates" document, but my IDE complains if I try to use NestedValueProvider.of to return a string as shown in the document. The only way I've been able to get NestedValueProviders to compile is as follows:
NestedValueProvider<String, String> pid = NestedValueProvider.of(
pipelineOptions.getDataflowProjectId(),
(SerializableFunction<String, String>) s -> s
);
(String pid = NestedValueProvider.of(...) results in the following error: "incompatible types: no instance(s) of type variable(s) T,X exist so that org.apache.beam.sdk.options.ValueProvider.NestedValueProvider conforms to java.lang.String")
I have the following in my pipelineOptions:
ValueProvider<String> getDataflowProjectId();
void setDataflowProjectId(ValueProvider<String> value);
Because of the volume of messages we're going to be processing, adding these checks at the front of the pipeline for every message that comes through isn't really practical; we'll hit daily account administrative limits on some of these calls pretty quickly.
Are templates the right approach for what I want to do? How do I go about actually productionizing this? Should (can?) I compile with maven into a jar, then just run the jar on a local dev/qa/prod box with my parameters and just not bother with ValueProviders at all? Or is it possible to provide a default to a ValueProvider and override it as part of the options passed to the template?
Any advice on how to proceed would be most appreciated. Thanks!
The way templates are currently implemented there is no point to perform "post-template creation" but "pre-pipeline start" initialization/validation.
All of the existing validation executes during template creation. If the validation detects that there the values aren't available (due to being a ValueProvider) the validation is skipped.
In some cases it is possible to approximate validation by adding runtime checks either as part of initial splitting of a custom source or part of the #Setup method of a DoFn. In the latter case, the #Setup method will run once for each instance of the DoFn that is created. If the pipeline is Batch, after 4 failures for a specific instance it will fail the pipeline.
Another option for productionizing pipelines is to build the JAR that runs the pipeline, and have a production process that runs that JAR to initiate the pipeline.
Regarding the compile error you received -- the NestedValueProvider returns a ValueProvider -- it isn't possible to get a String out of that. You could, however, put the validation code into the SerializableFunction that is run within the NestedValueProvider.
Although I believe this will currently re-run the validation everytime the value is accessed, it wouldn't be unreasonable to have the NestedValueProvider cache the translated value.

How does TFS's convertworkspaceitem work?

I'm trying to follow the instructions for deploying a database via TFS build listed here:
http://www.mytechfinds.com/articles/software-testing/6-test-automation/64-db-deployment-tfs
The instructions include notes about how to configure a ConvertWorkspaceItem element. I've followed the directions, but TFS remains unhappy with my setting for 'Result' and 'Workspace'. For now, I simply entered the text from the directions ('dbproj' and 'Workspace', respectively). TFS complains about my values:
Compiler error(s) encountered processing expression "dbproj". 'dbproj' is not declared. It may be inaccessible due to its production level.
I'm trying to find basic tutorial information on the ConvertWorkspaceItem element, but other than the MSDN reference page there isn't a lot of info. Does anyone know much about configuring this element?
You need to specify valid variable names for both of these properties. there should already be a variable declared in the workflow called workspace, You will need to declare a variable of type string that you wish to receive the result of this activity and specify it's name as the Result property. It looks like in your linked article the author must have already created a variable called dbproj. At the bottom of the workflow designer is a variables tab where you can define your own variables.

Resources