I am new with the usage of for ***'Address use ***. And I was wondering what are the limitation of this usage. So I created the following procedure:
procedure letshack (A : System.Address) is
My_String : String(1..100000);
for My_String'Address use A;
begin
Put(My_String);
end;
And this raise a EXCEPTION_ACCESS_VIOLATION while the same code with a String that is 100 length don't raise it. More over if i don't use the integer address, this code works properly.
So what are the limitation of for ***'Address use *** usage.
Ps : I am using Ada 95 but any information is welcome.
Edit:
I understand a part of the behavior. And this is what I suppose.
When you start your program a certain stack is allocated and you can write and read in it. Indeed I Wrote the 5th byte with an integer address
Real Addresses |----------------------------| Virtual Addresses
0x48000|Stack Origine |0x00
| |
| |
| |
| |
|End of Stack |
0x48000+range|----------------------------|0x00+range
And you get EXCEPTION_ACCESS_VIOLATION if you are out of stack. It seems strange for a "strong" language if it is right. Because it means you can rewrite your own stack and make bad behave.
Finnaly found the behavior.
When you start your program the addresses you use are virtual ones in a page.
And the part of the system that handle virtual adress make it for a certain size of memory that is allocated to your process which is constant depending on your system as show the following schema:
Real Addresses |----------------------------| Virtual Addresses
0x48000|Begin of the virtual address|0x00
|range |
| |
| |
|End of the virtual address |
|range |
0x48000+range|----------------------------|0x00+range
You can do anything without allocating variable in it. For example on my windows this size is 4096 bytes according to the variable si.dwPageSize in <windows.h>.
And I tested my String can be 4096 bytes long but not 4097 bytes. I must now test it on my embedded system but seems close to the truth.
If you have ensured that you have allocated 100_000 consecutive characters in a readable part of memory starting at A, then it should work.
If A is the address of another Ada entity, it is not supposed to work.
Related
I add the metadata "metering.server_group":"corey-group" to an instance while creating, and check it by using nova show, it is applied, then I check the Gnocchi resource using gnocchi resource show --type instance ${instance-id}, the attribute server_group is None in the begining, but after a while, it will be applied (always on the hour, ex: 07:00, 08:00...), I have no idea what happens, I think this issue will cause Gnocchi gets incorrect datasets while doing aggregation, so I spent some times to troubleshoot it.
First of all, the attributes of Gnocchi resource stored in database:
MariaDB [(none)]> use gnocchi
MariaDB [gnocchi]> select * from resource_type where name='instance';
# check its tablename, ex: rt_xxxxxx
MariaDB [gnocchi]> select * from rt_xxxxxx where display_name='corey-vm';
+----------------+---------------------+-----------+--------------------------------------+-------------------------+------------------+---+
| display_name | host | image_ref | flavor_id | server_group | id | flavor_name |
+----------------+---------------------+-----------+--------------------------------------+-------------------------+------------------+---+
| corey-vm | corey-test-com-001 | NULL | 26e46b4c-23bd-4224-a609-29bd3094a18e | NULL | xxxxxx | corey-flavor |
+----------------+---------------------+-----------+--------------------------------------+-------------------------+------------------+---+
As you can see, the column server_group should be corey-group, but it is always NULL when the instance is just created, and seems like ceilometer updates the resource per hour on the hour.
I added some log in the file ceilometer/publisher/gnocchi.py, and found that it updates resource every minutes, but the variable resource_extra gets server_group only on the hour, that's why it is None is the begining.
Here are some parts of the logs
2020-11-09 11:59:15 DEBUG ceilometer.publisher.gnocchi Resource {'host': u'test-com-002', 'display_name': u'vm-001', 'flavor_id': u'xxx', 'flavor_name': u'xxx'} publish_samples /usr/lib/python2.7/site-packages/ceilometer/publisher/gnocchi.py:345
2020-11-09 12:00:15 DEBUG ceilometer.publisher.gnocchi Resource {'host': u'test-com-002', 'display_name': u'vm-001', 'flavor_name': u'xxx', 'server_group': 'corey-group'} publish_samples /usr/lib/python2.7/site-packages/ceilometer/publisher/gnocchi.py:345
2020-11-09 12:01:15 DEBUG ceilometer.publisher.gnocchi Resource {'host': u'test-com-002', 'display_name': u'vm-001', 'flavor_id': u'xxx', 'flavor_name': u'xxx'} publish_samples /usr/lib/python2.7/site-packages/ceilometer/publisher/gnocchi.py:345
But I stuck at this point, I can't understand why the variable resource_extra can't gets server_group each time. What causes this happpening exactly? (Running on Queens)
I would appreciate any ideas.
Update 09/11/2020
After some days of troubleshooting, I still can't find the root cause.
But I found a command line to apply the 'server_group' manually, that can help me to avoid Gnocchi gets incorrect datasets to aggregate.
Here it is:
gnocchi resource update --type instance -a server_group:corey-group ${resource_id}
Update 11/11/2020
I tried to grep the integer 3600 and modify them to 300, but nothing changed, below are what I've tried.
/etc/ceilometer/ceilometer.conf
[compute]
resource_cache_expiry = 300
ceilometer/compute/discovery.py
cfg.IntOpt('resource_cache_expiry',
default=300,
ceilometer/publisher/zaqar.py
DEFAULT_TTL = 300
Update 12/11/2020
I can't reproduce this issue on Pike.
Maybe you can refer to the following discussions:
Heat autoscaling with gnocchi based aodh alarms requires use of naive instance_discovery_method setting with ceilometer compute agents?
According to the reference, try to change the default instance_discovery_method from "libvirt_metadata" to "naive" in ceilometer config file, like this:
[compute]
instance_discovery_method = naive
Switching to "naive" resolves this issue, however it obviously generates load on the Nova API for metadata retrieval.
Assume that a CPU pointer(cpu_ptr_) already exists, then I create a buffer for gpu(cl_gpu_mem_). The problem is that when I map the gpu buffer to a cpu pointer(mapped_ptr), the mapped_ptr is not equal to the original pointer (cpu_ptr_), which causes that CHECK_EQ(mapped_ptr, cpu_ptr_) raises an error.
cl_gpu_mem_ = clCreateBuffer(ctx.handle().get(),
CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
size_, cpu_ptr_, &err);
void *mapped_ptr = clEnqueueMapBuffer(
ctx.get_queue().handle().get(),
cl_gpu_mem_,
true,
CL_MAP_READ | CL_MAP_WRITE,
0, size_, 0, NULL, NULL, NULL);
CHECK_EQ(mapped_ptr, cpu_ptr_)
<< "Device claims it supports zero copy"
<< " but failed to create correct user ptr buffer";
I don't know why this error occurs at all. Would you please give me any advice for this problem, or any solution to it. Thank you very much.
OpenCL implementations are free to mirror the host pointer (making it non-zero copy). On devices that support true zero copy (e.g. Intel GPU), there are still typically constraints that impose whether we can really use that host allocation directory or must mirror it. On Intel the host address must be page aligned and a the length must be a multiple of 128 bytes (an even cacheline). (I typically just page align both.) I am not sure what AMD and other's requirements are.
Look into aligned_alloc or overallocate a couple extra pages via and use a page boundary for the base.
Is there a simple way to prove if a network adapter is working? Perhaps some IP like localhost (127.0.0.1) which is always available regardless of which network I'm connected to; only one that only shows if my wireless network adapter's working? Or perhaps there's some simple diagnostic check to confirm this?
I've tagged this question as PowerShell as that's my preferred language; but I can figure out ways to integrate with any other solutions which may be suggested.
Tried so far
I thought of checking the adapter's properties and found there is a status and an IP; I figured that if there were an assigned IP or a connected status that would prove that all's working; sadly those properties are blank and unknown, so I can't use them.
$adapter = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like '*Wireless*'}
$adapter.Status #returns 2; i.e. unknown
$adapter.NetworkAddresses #is blank
Background
I have an issue where I hibernate my laptop whilst docked then bring it back online no longer docked it loses its wireless connection and requires that the adapter be restarted. The same issue is mentioned in this post: Command/Powershell script to reset a network adapter
I'm hoping to use the above code to automatically resolve the issue by scheduling a task to run when my computer comes out of suspension (e.g. https://superuser.com/a/149924/156700).
Sometimes I'll be on my home network, where the only device to ping is my router, sometimes I'll be on my office network where there's a range of machines I could ping, and sometimes I'll be elsewhere... so determining a good target candidate to test whether my network adapter needs a restart by pinging some external device is more complex than ideal.
I want to run a test before resetting so that I only reset when required. It will also be useful to check once a reset has completed should I wish to queue other tasks which require network presence to complete.
It seems the WMI class Win32_NetworkAdapter has an Availability property.
https://msdn.microsoft.com/en-us/library/aa394216(v=vs.85).aspx
There are a range of values which could represent "working"; for now I've gone with only status 3; i.e. where everything's working 100% as expected / there's no concerns about potential degredation. That may be something worth amending depending on scenario.
function Test-NetworkAdapter {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]$AdapterNameMask
,
[Parameter(Mandatory = $false)]
[int[]]$HealthyStatusses = #(3) #100% working on full power; for list of other possible values, see https://msdn.microsoft.com/en-us/library/aa387884(v=vs.85).aspx
)
process {
Get-WmiObject -Class Win32_NetworkAdapter `
| Where-Object {$_.Name -like $AdapterNameMask} `
| Select-Object #{Name='Working';Expression={$healthyStatusses -contains $_.Availability}}
}
}
function Reset-NetworkAdapter {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]$AdapterNameMask
)
process {
Get-WmiObject -Class Win32_NetworkAdapter `
| Where-Object {$_.Name -like $AdapterNameMask} `
| %{ #in case multiple matches, loop through all
$_.Disable()
$_.Enable()
}
}
}
[string]$wirelessAdapterMask = '*Wireless*'
#I could probably improve this to cope better should there be multiple matches / only resetting those with issues... but for now this meets my requirement
if (-not (Test-NetworkAdapter $wirelessAdapterMask)) {
Reset-NetworkAdapter $wirelessAdapterMask
}
I've changed the IP on the global zone. Now I want to change the non-global zones.
I login with zlogin and use
ipadm delete-addr net0/?
There is a ? behind net0/
So I can't delete and set new.
Is there another way to change the IP of this zone?
From the global zone, you might check the output of:
$ dladm | grep <zone-name>
$ dladm show-linkprop <zone-name>/<iface>
zonename/aggr0 allowed-ips rw 10.2.42.142 10.2.42.142 -- --
Then, you should be able to change it using:
$ dladm set-linkprop -p allowed-ips=10.x.y.z zonename/aggr0
This might do the trick, I know if you have the link-protection to allow only listed IP address, this will update the list without the need for a reboot.
NOTE: I don't have a test zone available to actually verify this, but I know I already did this once in the past and it actually worked...
I am dealing with Message Passing IPCS method. I do have few question regarding this:
KEY field in ipcs -q shows me 0x00000000 what does this means ?
Can i see what messsage is passes using msqid ?
If two entries are present (for a particular user) after executing command ipcs -q. Does this means that two messages were passed by this particular user ?
If used-bytes and message fields are set as 0 what does this mean?
Is there away to see if message queue is full or not?
How many queues can we have for one particular user?
I tried goggling, but was not able to find answer to these questions.
Please help
1. The "key" field of the Shared memory segments is usually 0x00000000. This indicates the IPC_PRIVATE key specified during creation of the shared memory segment. The manual of shmget() contains more details.
2. AFAIK, this cannot be done. If any msg is "de-queued" from the msgQ, then the intended receiver will not see it.
3. The 2 entries in the list of message queues indicates that there are currently 2 active message queues on the system identified by their corresponding unique keys.
Creating additional msgQ : ipcmk -Q
Deleting an existing msgQ : ipcrm -Q <unique-key>
4. The used-bytes and messages fields set to 0 indicate that currently no transfers have occurred using that particular msgQ.
5. Currently one way to do this to obtain the number of msgs currently queued-up in the msgQ programmatically as shown in the following C snippet. Next this can be compared with the size of the msgQ as demonstrated in this answer.
int ret = msgctl(msqid, IPC_STAT, &buf);
uint msg = (uint)(buf.msg_qnum);
printf("msgs in Q = %u\n", msg);
6. There exists a limit on the total memory used by all the msgQs on the system combined together. This can be obtained by ulimit -q. The amount of bytes used in a msgQ is listed under the used-bytes column in the output of ipcs -Q. The total number of msgQs is limited only by the amount of memory available to create a new msgQ from the msgQ memory pool limit seen above.
Also checkout the latter part of this answer for a few sample operations on POSIX message queues.