I know it's strange, but it will helpful.
I found two ways:
UNIX timestamp, it can keep absolute increment unless the datetime of the system(linux) is not modified unexpectedly.
Maintain a value manually such as in file/sqlite/mysql. But it difficult to do this in my situation.
Is there some value or some method in linux os?
Sorry, I discussed this issue with my friend. They think it maybe a philosophical problem:)
Related
I used to use a program finddupe on Windows (XP) which checked for duplicate files and offered to replace by hardlinks.
This calculated a hash of the 1st 32K, only checking the balance on match. I have the source (for VC++6), but was wondering if there is a Linux/OSX equivalent before I try to port it, although I suspect it may be better to write a new program in a higher level language.
I've found fdupes to be helpful for me.
If you are looking to write your own quick script, I would suggest looping over files and using cmp as it allows you to easily stop comparison after the first mismatched byte.
There are many similar tools. See here
They may not be part of standard distribution.
I have used fslint before and found it to be sufficient for my needs.
Linus Torvalds mentioned in a talk that path name lookup in Linux is the fastest of all OSes, and that can happen in 1000-core machines without any slow downs. He mentioned this work happened in the last 18 months, but I can't find any references to the details of this development. Are there any documents explaining it?
Check out your /usr/src/linux/Documentation/filesystems for the file path-lookup.txt or go to http://www.mjmwired.net/kernel/Documentation/filesystems/path-lookup.txt - it explains it in detail.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Does readdir() guarantee an order?
I'm guessing this isn't the case, and I'd need to manually check the name of each entry instead of just skipping the first couple. Is that correct?
The POSIX standard does not guarantee anything about the order of directory entries whatsoever. As such, if you're interested in filtering out . and .., you do need to compare for them.
No, you should never rely on finding . and .. first (although it almost always happens).
I remember one case when I had problems with such an assuption (on ReiserFS they were not found first, but it was an old version of ReiserFS, now it may be different).
It is not in the standard, but I have never seen them in any other place, but the first two. But, just in case, if you don't realy mind the time that much, I would do the check.
I want to break the dependency on the system clock in my application as it can be tampered with. I found this for JAVA. Can anyone point me to something like this or something that helps me achieve this for c++?
You do realize that is just a web call? Someone can tamper with it by doing a man in the middle attack on the web call.
(yes it is harder than just changing the date, but unless you are talking to a secure host it could be intercepted).
I assume you are doing this for some kind of "expire demo code after it has ran for 30 days?" If so, there may be better ways to do that...
You mean something like an NTP Class (this one looks to use boost)? I have not used this one, so ymmv.
In LabVIEW, is it possible to tell from within a VI whether an output terminal is wired in the calling VI? Obviously, this would depend on the calling VI, but perhaps there is some way to find the answer for the current invocation of a VI.
In C terms, this would be like defining a function that takes arguments which are pointers to where to store output parameters, but will accept NULL if the caller is not interested in that parameter.
As it was said you can't do this in the natural way, but there's a workaround using data value references (requires LV 2009). It is the same idea of giving a NULLÂ pointer to an output argument. The result is given in input as a data value reference (which is the pointer), and checked for Not a Reference by the SubVI. If it is null, do nothing.
Here is the SubVI (case true does nothing of course):
And here is the calling VI:
Images are VI snippets so you can drag and drop on a diagram to get the code.
I'd suggest you're going about this the wrong way. If the compiler is not smart enough to avoid the calculation on its own, make two versions of this VI. One that does the expensive calculation, one that does not. Then make a polymorphic VI that will allow you to switch between them. You already know at design time which version you want (because you're either wiring the output terminal or not), so just use the correct version of the polymorphic VI.
Alternatively, pass in a variable that switches on or off a Case statement for the expensive section of your calculation.
Like Underflow said, the basic answer is no.
You can have a look here to get the what is probably the most official and detailed answer which will ever be provided by NI.
Extending your analogy, you can do this in LV, except LV doesn't have the concept of null that C does. You can see an example of this here.
Note that the code in the link Underflow provided will not work in an executable, because the diagrams are stripped by default when building an EXE and because the RTE does not support some of properties and methods used there.
Sorry, I see I misunderstood the question. I thought you were asking about an input, so the idea I suggested does not apply. The restrictions I pointed do apply, though.
Why do you want to do this? There might be another solution.
Generally, no.
It is possible to do a static analysis on the code using the "scripting" features. This would require pulling the calling hierarchy, and tracking the wire references.
Pulling together a trial of this, there are some difficulties. Multiple identical sub-vi's on the same diagram are difficult to distinguish. Also, terminal references appear to be accessible mostly by name, which can lead to some collisions with identically named terminals of other vi's.
NI has done a bit of work on a variation of this problem; check out this.
In general, the LV compiler optimizes the machine code in such a way that unused code is not even built into the executable.
This does not apply to subVIs (because there's no way of knowing that you won't try to use the value of the indicators somehow, although LV could do it if it removes the FP when building an executable, and possibly does), but there is one way you can get it to apply to a subVI - inline the subVI, which should allow the compiler to see the outputs aren't used. You can also set its priority to subroutine, which will possibly also do this, but I wouldn't recommend that.
Officially, in-lining is only available in LV 2010, but there are ways of accessing the private VI property in older versions. I wouldn't recommend it, though, and it's likely that 2010 has some optimizations in this area that older versions did not.
P.S. In general, the details of the compiling process are not exposed and vary between LV versions as NI tweaks the compiler. The whole process is supposed to have been given a major upgrade in LV 2010 and there should be a webcast on NI's site with some of the details.