Search Results

Search found 35 results on 2 pages for 'hao'.

Page 1/2 | 1 2  | Next Page >

  • pthreads_setaffinity_np: Invalid argument?

    - by hahuang65
    I've managed to get my pthreads program sort of working. Basically I am trying to manually set the affinity of 4 threads such that thread 1 runs on CPU 1, thread 2 runs on CPU 2, thread 3 runs on CPU 3, and thread 4 runs on CPU 4. After compiling, my code works for a few threads but not others (seems like thread 1 never works) but running the same compiled program a couple of different times gives me different results. For example: hao@Gorax:~/Desktop$ ./a.out Thread 3 is running on CPU 3 pthread_setaffinity_np: Invalid argument Thread Thread 2 is running on CPU 2 hao@Gorax:~/Desktop$ ./a.out Thread 2 is running on CPU 2 pthread_setaffinity_np: Invalid argument pthread_setaffinity_np: Invalid argument Thread 3 is running on CPU 3 Thread 3 is running on CPU 3 hao@Gorax:~/Desktop$ ./a.out Thread 2 is running on CPU 2 pthread_setaffinity_np: Invalid argument Thread 4 is running on CPU 4 Thread 4 is running on CPU 4 hao@Gorax:~/Desktop$ ./a.out pthread_setaffinity_np: Invalid argument My question is "Why does this happen? Also, why does the message sometimes print twice?" Here is the code: #define _GNU_SOURCE #include <stdio.h> #include <pthread.h> #include <stdlib.h> #include <sched.h> #include <errno.h> #define handle_error_en(en, msg) \ do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0) void *thread_function(char *message) { int s, j, number; pthread_t thread; cpu_set_t cpuset; number = (int)message; thread = pthread_self(); CPU_SET(number, &cpuset); s = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset); if (s != 0) { handle_error_en(s, "pthread_setaffinity_np"); } printf("Thread %d is running on CPU %d\n", number, sched_getcpu()); exit(EXIT_SUCCESS); } int main() { pthread_t thread1, thread2, thread3, thread4; int thread1Num = 1; int thread2Num = 2; int thread3Num = 3; int thread4Num = 4; int thread1Create, thread2Create, thread3Create, thread4Create, i, temp; thread1Create = pthread_create(&thread1, NULL, (void *)thread_function, (char *)thread1Num); thread2Create = pthread_create(&thread2, NULL, (void *)thread_function, (char *)thread2Num); thread3Create = pthread_create(&thread3, NULL, (void *)thread_function, (char *)thread3Num); thread4Create = pthread_create(&thread4, NULL, (void *)thread_function, (char *)thread4Num); pthread_join(thread1, NULL); pthread_join(thread2, NULL); pthread_join(thread3, NULL); pthread_join(thread4, NULL); return 0; }

    Read the article

  • Ubuntu 12.10 Wine Crash Error Help

    - by Hao
    I'm trying to get wine to work for Hawken. I used winetricks and installed all the necessary components. Wine works fine with other games I have installed but when I try to run Hawken it crashes while loading with the following error: fixme:iphlpapi:CancelIPChangeNotify (overlapped 0xf2afb8): stub I'm new to Ubuntu so I have no idea how to fix this. Any help would be much appreciated. *Update: I've done some backtracking and it seems that this error is caused by the launcher not wine itself.

    Read the article

  • What CPU hardware performance counter tool do you guys use?

    - by Hao Shen
    I just want to know the popular tool that I can use. Originally, I used Perfmon2. However, recently, I installed the lastest Ubuntu 12 on my Ivy Bridge i7 machine. Then there is some compilation error for the Pfmon. :< From here http://comments.gmane.org/gmane.comp.linux.perfmon2.devel/3255 , it seems that the Perfmon2 will not work after the kernel 2.6.30. So it suggests to use perf tool. I just want to confirm is there any popular application level performance counter monitor tool which can be used for the later kernel version?

    Read the article

  • printing foreign text for PHP on UBUNTU and CENTOS

    - by hao
    Hey guys, I am using domdocuments and using things like $div-nodeValue to obtain certain info from a web page. On my ubuntu machine when i do php crawl.php everything is displayed properly in Chinese (the page is in UTF-8). However on my CENTOS machine using the same code I get æ´å¤åå¸ when I print in the terminal. and when I save it to the database, the characters are also messed up. One thing I noticed is that when I do print $content, both systems display them properly.

    Read the article

  • Why does my DSDT table is different from what I found online?

    - by Hao Shen
    I have found a field in DSDT table where I want to modify from here http://www.ztex.de/misc/c2ctl.e.html Generally, I want to modify the _PSS field about the processor so that I can have more frequency levels available in the CPUfreq driver interface. I try to use this command to dissemble the DSDT table from my Desktop(Linux2.6.29,Intel CORE 2): cat /proc/acpi/dsdt > dsdt.aml iasl -d dsdt.aml Then I have a file dsdt.dsl as following(very long, so I just show the beginning of the file): /* * Intel ACPI Component Architecture * AML Disassembler version 20090123 * * Disassembly of dsdt.aml, Mon May 6 20:41:40 2013 * * * Original Table Header: * Signature "DSDT" * Length 0x00003794 (14228) * Revision 0x01 **** ACPI 1.0, no 64-bit math support * Checksum 0x46 * OEM ID "DELL" * OEM Table ID "dt_ex" * OEM Revision 0x00001000 (4096) * Compiler ID "INTL" * Compiler Version 0x20050624 (537200164) */ DefinitionBlock ("dsdt.aml", "DSDT", 1, "DELL", "dt_ex", 0x00001000) { Method (DBIN, 0, NotSerialized) { Noop } Scope (\) { Device (_SB.VBTN) ................... But I can not find the _PSS field as shown in the website I have given above. I do not know why? I am sure the current cpufreq driver shows 4 frequency levels available. So at least there should be something in the table showing this..right? Has anybody here played with the DSDT table before? Thanks,

    Read the article

  • is it possible for a router to provide different gateway?

    - by Hao
    i have tp-link wireless router 192.168.10.188, i was can make it function as DHCP provider(range 192.168.10.100 to 192.168.10.109). the only thing that i cannot make it work as intended, is for it to provide different gateway (192.168.10.1), the computers that obtain IP from that router properly get everything(dynamic IP and dns IP), but there is no function on that router to provide different gateway, the computers always get the router's address(192.168.10.188) as gateway. is there a router that can provide different gateway other than its own address? or the question should be, is the dhcp of a router can provide different gateway other than its own address? note: i cannot make the wireless router address as 192.168.10.1, we have main router(non-wireless, address is 192.168.10.1) that is connected directly to internet

    Read the article

  • what to do when Bing api provides inaccurate results

    - by hao
    I am trying to use the bing Phonebook search for locations in China, but all the latitude and longitude are inaccurate. Using the following http://api.bing.net/xml.aspx?AppId=appid&Query=nike&Sources=Phonebook&Latitude=39.9883699&Longitude=116.3309665&Radius=30.0&Phonebook.Count=10&Phonebook.Offset=30 I get multiple locations with the same latitude and longitude, and the rounding is off as well. The latitude and longitude will always end with either .x00001 or .0. The results from the pho:LocalSerpUrl http://www.bing.com/shenghuo/default.aspx?what=nike&where=&s_cid=ansPhBkYp01&ac=false&FORM=SOAPGN /pho:LocalSerpUrl Is right, but the results from the returned xml is off. Also it seems users outside of China can't hit that url and get the result. So I am wondering how I can contact bing and inquire about this problem

    Read the article

  • How to explain to users the advantages of dumb primary key?

    - by Hao
    Primary key attractiveness I have a boss(and also users) that wants primary key to be sophisticated/smart/attractive control number(sort of like Social Security number, or credit card number format) I just padded the primary key(in Views) with zeroes to appease their desire to make the control number sophisticated,smart and attractive. But they wanted it as: first 2 digits as client code, then 4 digits as year year, then last 4 digits as transaction number on that client on a given year, then reset the transaction number of client to 1 when next year flows. Each client's transaction starts with 1. e.g. WM20090001, WM20090002, BB2009001, WM20100001, BB20100001 But as I wanted to make things as simple as possible, I forgo embedding their suggested smartness in primary key, I just keep the primary key auto increments regardless of client and year. But to make it not dull-looking(they really are adamant to make the primary key as smart control number), I made the primary key appears to them smart, on view query, I put the client code and four digit year code on front of the eight-zero padded autoincrement key, i.e. WM200900000001. Sort of slug-like information on autoincremented primary key. Keeping primary key autoincrement regardless of any other information, we are able keep other potential side effects problem when they edit a record, for example, if they made a mistake of entering the transaction on WM, then they edit the client code to BB, if we use smart primary key, the primary keys of WM customer will have gaps in their control number. Or worse yet, instead of letting the control numbers have gaps/holes, the user will request that subsequent records of that gap should shift up to that gap and have their subsequent primary keys re-adjust(decremented). How do you deal with these user requests(reasonable or otherwise)? Do you yield to their request? Or just continue using dumb primary key and explain them the repercussions of having a very smart/sophisticated primary key and educate them the significant advantages of having a dumb primary key? P.S. quotable quote(http://articles.techrepublic.com.com/5100-10878_11-1044961.html): "If you hold your tongue the first time users ask what is for them a reasonable request, things will work a lot better in the end."

    Read the article

  • How to expand URLs in C#?

    - by Hao Wooi Lim
    If I have a URL like http://popurls.com/go/msn.com/l4eba1e6a0ffbd9fc915948434423a7d5, how do I expand it back to the original URL programmatically? Obviously I could use an API like expandurl.com but that will limits me to 100 requests per hour.

    Read the article

  • Change the get parameters in the address bar in jquery

    - by hao
    when you search on yelp, by adding additional search parameters the page does not reload. I think the results are changed based on ajax, however when you click on one of the restaruants and go back to the previous page. All of the parameters are still there. I noticed the address bars change as the parameters change. I found http://www.asual.com/jquery/address/ but it seems to add # at the end of the url. Is there a way to make it simply like index.php?xyz=1 without refreshing the page

    Read the article

  • Improve drawingvisual render's speed

    - by Michael Hao
    I create my own FrameworkElement and override VisualChildrenCount{get;} and GetVisualChild(int index) by returning my own DrawingVisual collection instance.I have override OnRender . I will add 20-50 DrawingVisuals in this FrameworkElement ,every DrawingVisual will have 2000 line segments.The logic value of these points between 0 to 60000.when I zoom into 1:1 the FrameworkElement 's Height will be 60000, the rending time will be 15 minutes!! How do I improve the rending performance ?

    Read the article

  • How to refresh Mono ASP.NET page without restarting the web server?

    - by Hao
    When I make changes to a file, Mono ASP.NET doesn't see my changes, I have to do this: sudo /etc/init.d/apache2 restart I remember hen Mono ASP.NET executes ASP.NET it caches the compilation somewhere. Before, when the updated page doesn't come up, I just delete that cached compiled code. I just forgot the exact path How to make Mono ASP.NET that I have changed the program without restarting the web server?

    Read the article

  • I cannot grok MVC, what it is, and what it is not?

    - by Hao
    I cannot grok what MVC is, what mindset or programming model should I acquire so MVC stuff can instantly "lightbulb" on my head? If not instantly, what simple programs/projects should I try to do first so I can apply the neat things MVC brings to programming. OOP is intuitive and easier, object is all around us, and the benefits of code reuse using OOP-paradigm instantly click to anyone. You can probably talk to anybody about OOP in a few minutes and lecture some examples and they would get it. While OOP somehow raise the intuitiveness aspect of programming, MVC seems to do the opposite. I'm getting negative thoughts that some future employers(or even clients) would look down upon me for not using MVC technology. Though I probably get the skinnable aspect of MVC, but when I try to apply it to my own project, I don't know where to start. And also some programmers even have diverging views on how to accomplish MVC properly. Take this for instance from Jeff's post about MVC: The view is simply how you lay the data out, how it is displayed. If you want a subset of some data, for example, my opinion is that is a responsibility of the model. So maybe some programmers use MVC, but they somehow inadvertently use the View or the Controller to extract a subset of data. Why we can't have a definitive definition of what and how to accomplish MVC properly? And also, when I search for MVC .NET programs, most of it applies to web programs, not desktop apps, this intrigue me further. My guess is, this is most advantageous to web apps, there's not much problem about intermixed view(html) and controller(program code) in desktop apps.

    Read the article

  • regular expression help

    - by hao
    <li class="zk_list_c2 f_l"><a title="abc" target="_blank" href="link"> abc </a>&nbsp;</li> how would i extract abc and link? $pattern="/<li class=\"zk_list_c2 f_l\"><a title=\"(.*)\" target=\"_blank\" href=\"(.*)\">\s*(.*)\s*<\/a>&nbsp;<\/li>/m"; preg_match_all($pattern, $content, $matches); the one i have right now doesnt seems to work

    Read the article

  • manipulating the geocoding webservices results through javascript?

    - by hao
    using http://maps.google.com/maps/api/geocode/json?address=xyz we get a json file I am wondering how can i maniupluate the results in javascript? How do i create the results object in javascript? http://code.google.com/apis/maps/documentation/geocoding/index.html#JSONParsing this doesnt really explain how they get the myJSONResult

    Read the article

  • Eidetic memory: What magic numbers you still remember?

    - by Hao
    Long before you practice writing readable code, what "magic numbers" you still remember up to this day? here's some of my list: 72 80 75 77 13 32 27 - up down left right enter space escape 1 2 4 128 - blue green red blink 67h 33h 17h - interrupt for EMS, mouse, printer function AH 9, interrupt 21 alt+219 for block ASCII alt+164 ñ 90 NOP 13 10 carriage return, line feed ascii 1 and 2 face, ascii 3 heart. no not this heart: <3 :-) debug -o72,10 -o71,12 clears the BIOS password. I don't know what those numbers mean, it's like a trade secret that gets shared with each other during college days. ascii 7 sounds a beep P.S. Somehow, remembering some of these magic numbers can help you in some tech problems, your keyboard is broken, the office pal's keyboard doesn't have accented characters. An anecdote, during college, one of my friend asked me how to remove the newlines in his Word document. Not having used Word so much then, I somehow "intuitively" guessed to find ^013 and replace it with blank. Well it works :-)

    Read the article

  • How to check if JavaScript object is JSON

    - by Wei Hao
    I have a nested JSON object that I need to loop through, and the value of each key could be a String, JSON array or another JSON object. Depending on the type of object, I need to carry out different operations. Is there any way I can check the type of the object to see if it is a String, JSON object or JSON array? I tried using typeof and instanceof but both didn't seem to work, as typeof will return an object for both JSON object and array, and instanceof gives an error when I do obj instanceof JSON. To be more specific, after parsing the JSON into a JS object, is there any way I can check if it is a normal string, or an object with keys and values (from a JSON object), or an array (from a JSON array)? For example: JSON var data = {"hi": {"hello": ["hi1","hi2"] }, "hey":"words" } JavaScript var jsonObj = JSON.parse(data); var level1 = jsonObj.hi; var text = jsonObj.hey; var arr = level1.hello; //how to check if level1 was formerly a JSON object? //how to check if arr was formerly a JSON array? //how to check if text is a string?

    Read the article

1 2  | Next Page >