w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to programmatically run a command with low IO priority and high niceness value on OS X
Edit: Fork and exec no more, since OSX can't really fork right. Single thread magic: setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_PROCESS, IOPOL_THROTTLE); system("nice -n 20 /usr/bin/purge"); setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_PROCESS, IOPOL_DEFAULT); This can go anywhere, in a dispatch block if you want, or anywhere in your application. No fork in sight. Also, feel free to replace system with NSTask if you want to stay ObjCish. How about a good old forknexec: #include <unistd.h> #include <sys/resource.h> And: if(fork()) { /* Set IO priority */ setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_PROCESS, IOPOL_THROTTLE); /*IO priority is inherited*/ execl("nice", "-n", "20", "/usr/bin/purge"); } Let's walk through this: fork: Nothing to see here setiopoli

Categories : Objective C

How scheduler gets called when a high priority task comes
Priority changes and is adjusted based on past CPU usage. The longer version In Linux, process priority is dynamic. The scheduler keeps track of what processes are doing and adjusts their priorities periodically; in this way, processes that have been denied the use of the CPU for a long time interval are boosted by dynamically increasing their priority. Correspondingly, processes running for a long time are penalized by decreasing their priority.

Categories : Linux

ThreadPool or BackgroundWorker for high-priority download?
To download this image ASAP, you really need to stop all other downloads. The bottleneck, more than likely, is the network bandwidth. Hence, you want all other downloads to stop taking any more bandwidth so that your detailed image can load ASAP. Thus, I would choose 1. The other choices don't stop downloads that are already in progress.

Categories : Multithreading

Create a high priority serial dispatch queue with GCD
is it a requirement that you have a custom queue? If not, you could look at dispatching a block to the high priority global queue, which you can retrieve using: dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0) keep in mind that this is the global queue so it may impact other concurrent operations.

Categories : Objective C

High priority queue over a lower one in ruby AMQP with RabbitMQ?
Can you try something like this. I am not sure if this produces what you need, but worth trying. 10.times do 10.times do exchange.publish "HIGH", :routing_key => high_queue.name end exchange.publish "LOW", :routing_key => low_queue.name end

Categories : Ruby

Azure Could Computing high availoability vs NEO4J high availability?
The short answer is probably yes. Windows Azure provide you infrastructure that allow you to build high availability system, it won't make any system high available by magic. As NEO4J is state-full, each node (with only one node Azure don't give you any SLA, you instance will be down) will need to share some state and the way to do it will be dependent on how NEO4J is working. So you will need to rely on NEO4J mechanism to do it. I don't know how NEO4J is working but you won't be able to skip designing an high available architecture around NEO4J using Windows Azure infra. Cloud may be a magic buzz word that can make things append on management level, but when we are on hard real world level Harry magic wand doesn't exist.

Categories : Neo4j

Why thread with lower priority get longer CPU time than thread with higher priority in this code
I suspect the example figures will be somewhat dependent upon both your platform and the author's (does the example run upon a single core?). The JVM thread prioritisation is OS/platform-specific. From this interesting document Linux priorities Under Linux, you have to go through more hoops to get thread priorities to function at all, although in the end, they may be more useful than under Windows. In Linux: thread priorities only work as of Java 6 onwards; for them to work, you must be running as root (or with root privileges via setuid); the JVM parameter -XX:UseThreadPriorities must be included So check your Java version, your Java invocation and your privileges. I suspect (!) you only satisfy one of those criteria (your Java/JVM version).

Categories : Java

quicksand sorting price values low to high / high to low
val() gives you a string, so > and < comparisons are lexographical (not numeric). Try wrapping the values in parseInt() or parseFloat(). Make sure to add appropriate error handling as well.

Categories : Jquery

Varnish High DB Connections In High Traffic
Mostly spiking backend connections has little to do with your varnish configuration but alot to do with the cachability of your site. Are there cookies that prevents you from caching efficiently? You can chose to strip them or remove all but chosen ones, there are examples for both on the varnish site. Do a varnishstat and check your hit rates during peaks. Is it a good cache hitratio? Is it the same as during low load? If it's the same or higher in low load it's easy to work on improving it at any time. Do a varnishtop -i txurl to see what requests are the most frequently sent to backend servers. Maybe it's some URLs that are just not cached due to faulty headers? Maybe some pages can be cached longer? Maybe some parts of the pages can be cached with ESI? Make sure your varnish is not

Categories : Mysql

Executing separate, isolated operations with Hibernate, sharing objects between operations
A transaction, basically, ensures that all the operations performed between the beginning and the end of the transaction are either sucessfully performed, or cancelled. So the state of the database either stays as it was before the beginning of a transaction (in case of a rollback), or contains all the modifications (insertions, updates, removals) done during the transaction (in case of a successful commit). So just open a transaction, do all the operations you want, and commit the transaction. In case of any exception, rollback the transaction. The state of the database will stay unmodified, or will contain all the removals and reinsertions you made during the transaction. Given that you don't really care about the reinsertions, you could also have a first transaction to remove everyth

Categories : Java

What are the advantages to using bitwise operations over boolean operations in Python?
If you want a concrete example of bitwise operators being used in the standard library, just look at the re library. According to the API, the flags are supposed to be bitwise ORed together. This allows you to pass a large number of options in a single argument. Consider the following options: re.compile(expression,re.I | re.M | re.X) vs. re.compile(expression,ignorecase=True,multiline=True,verbose=True) I think we can agree that the first version is a lot more compact at least. You may be thinking "Well, I like the second better -- after all, it is more explicit!" ... And you might have a case for that. But what if you had a colleague who generated a binary file in C and he told you that the header of the file contained a 32 bit integer field and that integer field stores the

Categories : Python

Locate run-time error for array operations and map operations
Compile your program with debug symbols "-g" and set the environment variable OCAMLRUNPARAM=b. Or use Printexc Google is your friend: http://www.mega-nerd.com/erikd/Blog/CodeHacking/Ocaml/exception_backtraces.html , http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printexc.html , ...

Categories : Arrays

AngularJS directive - setting order for multiple directive elements (not priority for directives, but priority for the elements)
OK, here's my solution, although it's more a template. Fiddle (check the console log to see the result) I've wrapped the foo directive in a fooParent directive, like so: <div foo-parent> <div foo run="3"></div> <div foo run="1"></div> <div foo run="2"></div> </div> The fooParent directive exists pretty much to do three things: Expose a function to foo items so they can be added to a general list Maintain a list of foos, which will be sorted during post-linking Process each foo in the run order specified. It looks like this: app.directive('fooParent', function() { var foos = []; return { restrict: 'A', controller: ['$scope', '$element', '$attrs', '$transclude', function($scope, $element, $attrs, $t

Categories : Javascript

When to use low < high or low + 1 < high for loop invariant
If your invariant is that the target must lie in low <= i <= high, then you use while (low < high); if your invariant is that the target must lie in low <= i < high then you use while (low + 1 < high). [Thanks to David Eisenstat for confirming this.]

Categories : Algorithm

Mixing C++11 threading operations with QThread operations
I can't think of a reason why you couldn't use c++11 mutexes with QThread. Locking a QMutex or C++11 mutex will have the same effect: you can't relock it unless it has been unlocked (or configured for recursive lock, if available). I don't think that the QMutex implementation is tightly coupled with QThread. I suppose both C++11 mutexes and QMutex rely on pthread when implemented in Linux. They probably both rely on the Windows API when implemented on Windows. Of course, feel free to correct me if I'm wrong. Btw, did you run any test usign C++11 mutex with QThread?

Categories : C++

probably css priority bug in chrome?
"#access a:visited" has higher specificity than "#access ul ul a". If you run through the algorithm at http://www.w3.org/TR/CSS21/cascade.html#specificity the former has a specificity of (0, 1, 1, 1) while the latter is (0, 1, 0, 3). Your modified selector ("#access ul ul.sub-menu a") has specificity (0, 1, 1, 3). The reason that Firefox is ignoring the line-height styling inside the :visited rule is explained in http://dbaron.org/mozilla/visited-privacy and in particular in the "It limits the CSS properties that can be used to style visited links" paragraph.

Categories : CSS

Priority of an OR statement SQL
You would get more than one record if you use just that. I would do something like: (The table in question will be scanned only once) Select top 1 * From dbo.SomeTable where WorkGroupId=2 or RoleId=2 Order by case when WorkGroupId=2 then 1 when RoleId=2 then 2 end

Categories : SQL

c++ operator mix using and priority is not what i want
How to do? You can't. There is no way to change the precedence order of C++ operators. And even if you could, this is probably a bad idea. It's considered bad practice to overload random operators like this. I would suggest sticking to C++ convention, and using << everywhere (as it's not clear to me why you need multiple different operators). However, it's not clear why you need operator overloading at all here. To me, this code would be much clearer written as: sql = bind("insert into test_table (tiny_col,short_col) values (?,?)", kk, jj);

Categories : C++

CSS Priority problems
Yes, it's normal: the specificity for the first selector is higher (id + tag) than for the the second one (just id), so the rules written there prevail. The easiest way to solve it is to add a tag to the second selector as well, making specificity of the selectors the same so that the last one can 'win' now: p#reportBoxTitle { padding-top: 5px; font-size: 18px; } Fiddle. But actually, I don't understand why you've used <p> here instead of <hN> selector: this paragraph is clearly a header of the report, and should not only be styled, but also marked in HTML accordingly. For example: <div id="reportBox"> <h3 id="reportBoxTitle">MAIN REPORT</h3> <p id="reportBoxContent">Promoting Investment in Agriculture</p> </div> Now y

Categories : HTML

CSS selectors priority
You can calculate the specificity of those selectors (here's a friendlier version): .menu > li has specificity 0,0,1,1 (11). ul > li has specificity 0,0,0,2 (2). .two has specificity 0,0,1,0 (10). The bold numbers are just the base-10 representations of the specificities. You won't always be able to write them that way, as 0,0,100,0 is also a valid specificity and must be represented in a base higher than 100. So back to your question: .menu > li > .two > ul > li, as class selectors are more specific than tag name (type) selectors.

Categories : HTML

How to get only Websphere MQ messages with a particular priority in C#?
As of now in MQ .NET, you can use MQC.MQMO_MATCH_MSG_ID and MQC.MQMO_MATCH_CORREL_ID match options to get messages that match message id or correlation id. Getting messages matching a Priority is not available. Alternatively you switch to using XMS .NETthat allows consumers to be created with SQL92 style selection string. For example you can create consumer with a selection string "JMSPriority > 3 AND manufacturer = 'Jaguar'" to receive only messages that have JMSPriority of 3 and manufacturer name as Jaguar.

Categories : C#

java Thread priority
The priority of a thread maps to some underlying priority on the operating system. It is possible (and likely) that multiple java priorities will map to the same OS priority. Just because you are using priorities 1-10 does not mean you will have 10 different priorities. This actual priority assigned to the thread varies depending on the operating system.

Categories : Java

Java operands priority x++ and *,+
Operands are evaluated left to right. So your code is equivalent to: int test1 = x * 4 + x; //2 * 4 + 2 x = x + 1; int temp = y; y = y + 1; // y = 3 int test2 = temp + y * 4; //2 + 3 * 4

Categories : Java

Android: Values priority
You can find the priority of resource folders here in this page. Basically it is used to support different devices and configurations. Android uses a certain logic to determine the best possible matching resource folder for a device. This is explained in this documentation page. Regarding your devices query: First: 480 * 800 hdpi v14 -- values-hdpi Second: 320 * 480 mdpi v17 -- values-mdpi Third: 720 * 1280 hdpi v17 -- values-w480 In the list provided by you, values-w480 (devices with lowest width of 480dp, only from API 13) has got the highest merit. So whichever device meets that criteria, it'll take resources from that folder. The values-vXX (devices with API >= XX) has got the lowest merit. So if the other folders are not taken, then only Android takes resources from this f

Categories : Android

Objective-c Priority Queue
I was unable to find an implementation of a priority queue, so I went ahead and made my own. I'm not sure how robust it is, but I hope it might point others in the right direction. PriorityQueue.h // // PriorityQueue.h // #import <Foundation/Foundation.h> #import "comparable.h" //Implements a priority queue. All objects in queue must implement the comparable protocol and must be all of the same type. The queue can be explicity typed at initialization, otherwise the type of the first object entered will be the type of the queue @interface PriorityQueue : NSObject{ NSMutableArray *queue; Class type; } - (id)init; - (id)initWithObjects:(NSSet *)objects; - (id)initWithCapacity:(int)capacity; - (id)initWithCapacity:(int)capacity andType:(Class)oType; //Queue will reject obje

Categories : Objective C

Why does thread priority have no effect?
If you have more then one CPU(-core) on your PC which is available this is "normal", as Thread 1 is running on CPU/core 1 and thread 2 on CPU/core 2. I think if you reporduce the same with more threads then available cores or running e.g. Prime95 in the background to use 100% of your CPU it should make a difference, but in case of <= threads then (available) CPUs/corse the scheduler will run each thread on its own core and (if they are doing ~ the same) they will finish the same time...

Categories : C#

How do I declare priority in SQL statements?
You would express it using parentheses and boolean logic in the where clause: SELECT * FROM tbl_tbl t WHERE (t.colA LIKE '%foo%' OR t.colA LIKE '%oof%') AND (t.colB LIKE '%bar%' OR t.colB LIKE '%bar%'); Do note that this is based on your example in the question. The second clause of the AND has two conditions that are the same. I assume this is a typo in the question, but not knowing the right pattern, I've left it in the answer.

Categories : SQL

Priority among route patterns
https://github.com/rack/rack/blob/master/lib/rack/urlmap.rb Priority doesn't determined in Rack::URLMap. It matched by full path of the resource, that you provide with map(){ ... }

Categories : Ruby

Change priority on Mutexes
What output are you expecting when you say it doesn't work? You are starting tHiPriorityTask and this is immediately reaching the semaphore, forcing tMePriorityTask to wait, even if it has a higher priority. Basically, having a higher priority it doesn't mean it can take over a locked semaphore, it just means that it's more likely to run when itself and its competitors are in the "ready" state. The only scenario where tMePriorityTask would run first, is when tHiPriorityTask is preempted before tryig to reach the semaphore, which I guess it's less likely because you started it first and it may go ahead and run the first instructions.

Categories : C

What is codeigniter's email priority?
The email priority setting sets the X-Priority header on the email. The handling of the header is left to the recipient application. It doesn't have any impact on the order or speed of sending emails, just that some email clients may choose to render messages with this header somewhat differently, for example, Outlook may flag the message as "High Importance" (two question marks = !!), with X-Priority set to 1.

Categories : Codeigniter

Autolayout Constraints Priority
You set the content compression resistance to high on label B: [labelB setContentCompressionResistancePriority: UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal]; This means that B will try not to be compressed below the intrinsic size given by the text. To make it also be as small as possible, you may also want to set the contentHuggingPriority- this will make it try to match the size of the text.

Categories : IOS

Select with priority on a column
You can repeat the match in the order by: SELECT SQL_CALC_FOUND_ROWS id, autor, dle_post.date AS newsdate, dle_post.date AS DATE, short_story AS story, dle_post.xfields AS xfields, title, descr, keywords, category, alt_name, comm_num AS comm_in_news, allow_comm, rating, news_read, flag, editdate, editor, reason, view_edit, tags, '' AS output_comms FROM dle_post WHERE dle_post.approve =1 AND MATCH ( title, short_story, full_story, dle_post.xfields ) AGAINST ( 'test' ) order by MATCH (title) AGAINST ('test') desc LIMIT 0 , 30 By the way, you shouldn't use limit without an order by clause. What you probably want is something more like this: SELECT SQL_CALC_FOUND_ROWS id, autor, dle_post.date AS newsdate, dle_post.date AS DATE, short_story AS story, dle_post.xfields AS xfields, ti

Categories : Mysql

How can I use priority queue in SWI-Prolog?
One easy way is to use a Key-Value pair list, which has the form: [1-state(Cost_so_far, ...), 2-state(...), 3-state(...)] Your integer value from the heuristic would be the key, the functor state (of whatever arity you need) would be the value. Note that this is the conventional way of keeping a list of pairs. You can use matching to get them out, for example, the state at the head of the queue would be: [Heuristic-state(A, B, C)|QueueRest] You should probably use the built-in keysort/2 for sorting it (very efficiently) every time you have added new states at the top of the queue.

Categories : Prolog

Postgresql distinct by priority
you have to use columns inside of distinct on in order by. select distinct on (postcards.id) postcards.id, postcards.title, rational from ( select postcards.id, postcards.title, some_complex_condition as rational from postcards ) as postcards order by postcards.id, rational From PostgreSQL documentation: The DISTINCT ON expression(s) must match the leftmost ORDER BY expression(s). The ORDER BY clause will normally contain additional expression(s) that determine the desired precedence of rows within each DISTINCT ON group So the distinct on will use recordset ordered by id, rational and take first record in recordset for each id.

Categories : SQL

not get sms even when set the highest priority and installed first
As the question you are linking to explains, once the GO SMS app's receiver gets called, they can call abortBroadcast(). Assuming they are using the highest priority possible (=2147483647), I would assume that the following snippet from the docs would apply: The order receivers run in can be controlled with the android:priority attribute of the matching intent-filter; receivers with the same priority will be run in an arbitrary order. However, since they always happen to intercept SMS before your app, I would assume that the magic is somewhere else. Among their permissions, they have the following: "android.permission.PERSISTENT_ACTIVITY" "android.permission.WRITE_SMS" "android.permission.READ_SMS" Do you mind trying a combination of these, to see if it affects the ordering o

Categories : Android

How to define sprite priority over other?
Sprite drawing order depends on the zOrder. Higher zOrder sprites are drawn on top of lower zOrder sprites. You can change the zOrder with: - (void)reorderChild:(CCNode *)child z:(NSInteger)zOrder

Categories : Objective C

CSS attribute selector priority
http://jsfiddle.net/8bG2j/2/ This should do it. Simply use a pseudoclass which is always true like a:not(s). It will raise your priority by the priority of the selector inside the :not statement. Alternatively, as stated in the comments, you can prefix it with an ul when you don't want to break with older browsers (like IE 8). You can do this if .ressource-list will be always a class of an <ul> tag.

Categories : CSS

nsoperationqueue with priority heap
There is a setQueueProperty method in NSOperation that can help you. From Apple Docs: Sets the priority of the operation when used in an operation queue. You should use priority values only as needed to classify the relative priority of non-dependent operations. Priority values should not be used to implement dependency management among different operation objects. If you need to establish dependencies between operations, use the addDependency: method instead. If you attempt to specify a priority value that does not match one of the defined constants, this method automatically adjusts the value you specify towards the NSOperationQueuePriorityNormal priority, stopping at the first valid constant value. For example, if you specified the value -10, this method would

Categories : IOS

Order Fields priority
It tries to order by the unique/primary key. In this case, orderno if it is your primary key. However, your query is laden with errors. e.g. The table aliases are used in the SELECT clause but are not specified in the FROM

Categories : SQL

Antlr token priority
FREE_TEXT_WORD in its current form is capturing everything. You need a non greedy lexer rule. Try changing FREE_TEXT_WORD: NON_SPACE+; to FREE_TEXT_WORD: NON_SPACE+?;.

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.