Why is CompareAndSwap instruction considered expensive?
I read in a book:
"Memory barriers are expensive, about as
expensive as an atomic compareAndSet()
instruction."
Thanks!
-(id)setBigObject:(BigObject *)abc{
self.wl = abc;
abc.smallObject = self.smallObject;
}
I have a abc, which is a big Object, when the user pass the bigObject, abc. I assign to my wl value, so , I write "self.wl = abc;", but I want my smallObject assign to the abc's smallObject, so, I do "abc.smallObject = self.smallObject; "
So, when I edit the smallObject in self, it will also changed in the abc's also? Am I right?
i want to help me to choose good books on algorithms
many people from this site say me that show me your code and now i ask u to help me to choose good books on algorithms please i have not books on algorithms and in case i decide to buy it of course must buy book which has high quality yes? so please any ideas ?links everything
I have to develop a whiteboard application in which both the local user and the remote user should be able to draw simultaneously, is this possible? If possible then any logic?
I have already developed a code but in which i am not able to do this, when the remote user starts drawing the shape which i am drawing is being replaced by his shape and co-ordinates.
This problem is only when both draw simultaneously.
any idea guys?
what is the diffrance between :
char const *p;
cost char *p;
char *const p;
??
and is there a good site where i can relearn c and c++?
it seems that i forgot it and job interviews doing me an hard time ...
Out of sheer curiosity. Hope none of you NDAs are violated or whatever.
Here are mine. I'm currently refactoring a massively coupled webapp. As it usually is, no comments and no documentation whatsoever.
if (paymentMethod == PaymentMethod.InAgency )
{
EmailController.SendBookingCreateEmails(booking);
this.DC.SubmitChanges();
return RedirectToAction("Result", new { id = booking.Id });
}
else if (paymentMethod == PaymentMethod.CreditCard)
{
return RedirectToAction("Pay", new { id = booking.Id });
}
else if(paymentMethod == PaymentMethod.MostravelBank || paymentMethod == PaymentMethod.MostravelCallback ||
paymentMethod == PaymentMethod.MostravelCardCredit || paymentMethod == PaymentMethod.MostravelCourierCash ||
paymentMethod == PaymentMethod.MostravelCourierPlasticCard)
{
isExclusive = true;
Log.TraceInformation("Started booking for Mostravel. Payment method: {0}", paymentMethod);
try
{
Log.TraceInformation("Sending emails");
EmailController.SendBookingCreateEmailsEx(booking);
Log.TraceInformation("Sent emails. Started booking");
MakeRealBooking(booking, DC.MailRuAgencies.First(a => a.Id == MvcApplication.DefaultMailRuAgencyId));
Log.TraceInformation("Finished booking");
}
catch(Exception ex)
{
Log.TraceEvent(TraceEventType.Error, 0, "Error while booking: {0}", ex.ToString());
}
What are you working on right now?
Iphone or blackberry or any other?
I do XHTML, CSS, Design, PHP work and use gmail, skype, firefox, twitter etc.
Which device would be helpful for me when i'm not at desk.
So I have a Linux program that runs in a while(true) loop, which waits for user input, process it and print result to stdout.
I want to write a shell script that open this program, feed it lines from a txt file, one line at a time and save the program output for each line to a file.
So I want to know if there is any command for:
- open a program
- send text to a process
- receive output from that program
Many thanks.
I am porting a streaming TCP app from Linux to Windows.
The app streams real-time audio data using a preexisting TCP protocol (so switching to UDP isn't an option). Further, I wish to avoid being "part of the problem" and requiring Administrator rights.
The Linux code uses getsockopt(... ,SOL_TCP, TCP_INFO, ..) to get the RTT (round trip time) information from the TCP connection. The application level uses this to throttle the amount of data sent over the connection (apparently to balance quality with latency).
Is there an equivalent to TCP_INFO on WIndows?
(google tells me that Win2K and later supports "TCP Timestamps" which would provide this information, but I've yet to find a way to get at it.
Thanks in advance.
Hi,
I'm writing a kernel module that reads from a /proc file.
When someone writes into the /proc file the reader will read it, but if it reads again while there is no "new" write, it should be blocked.
In order to remember if we already read, i need to keep a map of the latest buffer that process read.
To avoid that, I was told that there might be some redundant field inside the current- (task_struct struct) that i can use to my benefits in order to save some states on the current process.
How can I find such fields ? and how can i avoid them being overwritten ?
I read somewhere that i can use the offset field inside the struct in order to save my information there and i need to block lseek operations so that field will stay untouched.
How can I do so ? and where is that offset field, i can't find it inside the task_Struct.
Thanks
and I need to save for each process some information in order to map it against other information.
I can write a ma
G'day,
How do you work with someone when they haven't been able to see that there is a range of other languages out there beyond "The One True Path"?
I mean someone who hasn't grown up to realise that the modern software professional has a range of tools in his toolbox. Someone who has a well-equipped toolbox and then selects the best tool for the job at hand.
The person who's knee jerk reaction is, for example, "We must do this is C++!" "Everything must be done in C++!"
What's the best approach for these people? How do you open them up to the fact that "not everything is a nail."
cheers,
I have designed around 5 experimental languages and interpreters for them so far, for education, as a hobby and for fun.
One thing I noticed: The assembly-like language featuring only subroutines and conditional jumps as structures was much slower than the high-level language featuring if, while and so on. I developed them both simultaneously and both were interpreted languages. I wrote the interpreters in C++ and I tried to optimize the code-execution part to be as fast as possible.
My hypothesis: In almost all cases, performance of interpreted languages rises with their level (high/low).
Am I basically right with this? (If not, why?)
Hi,
Is there any reason behind using this date as standard for time manipulation? I have seen this standard in Java as well as in Python. These two languages I am aware of. Is other popular languages also follows the same standard?
Please describe.
I want to divide a list in "a specific number of" sublists.
That is, for example if I have a list List(34, 11, 23, 1, 9, 83, 5) and the number of sublists expected is 3 then I want List(List(34, 11), List(23, 1), List(9, 83, 5)).
How do I go about doing this? I tried grouped but it doesn't seem to be doing what I want.
PS: This is not a homework question. Kindly give a direct solution instead of some vague suggestions.
I know there are good books to start with, but let's make a short list of 3-5 books, i don't think only one book could help you in the way of becoming a good architect. I read some time ago that an architect takes years to have the knowledge and the ability to make good decisions. Suppose someone has the potential, what is the way?
Please, answers with books that doesn't repeat over the same theme, making your learning process widely.
One short list per answer. Vote up that you think are the best ones.
Thanks.
One of the drivers I'm developing has caused a BSOD. Unfortunately a dump file was not created since it was not configured / low resources. I was trying to reproduce this crash but no luck so far.
Is there any way to get some info using WinDbg or any other tool?
I have this information:
A screenshot of the BSOD
The .sys file.
Its pdb
The source code
The machine it was crashed on
I have everything except the dump itself.
Your help will be much appreciated.
As I said above, no dump (/minidump) exists. This is the actual problem.
For this specific crash, I know I won't be able to get the stack. Just getting the specific line of code will be good enough. Because the BSOD contains the module's address, it seems like there should be a way to detect which line exactly is it. As I mentioned above, I do have the .sys file, the pdb and the source code.
This is the specific code taken from MSDN: SYSTEM_SERVICE_EXCEPTION.
How can I know from there what was the specific line? and/or the specific exception raised?
When thinking in a functional mindset, given that functions are supposed to be pure, one can conclude any function with no arguments is basically just a value.
However, reallity gets in the way, and with different inputs, I might not need a certain function, and if that function is computationally expensive, I'd like to not evaluate it if it's not needed.
I found a workaround, using let func _ = ... and calling it with func 1 or whatever, but that feels very non-idiomatic and confusing to the reader.
This boils down to one question: In F#, Is there a proper way to declare a function with zero arguments, without having it evaluated on declaration?
If you're trying to build an application that needs to have the highest possible sustained network bandwidth, for multiple and repetitive file transfers (not for streaming media), will having 2 or more NICs be beneficial?
Hi all,
I'm finding a way to write a mobile application that could stimulate clicking some buttons on the phone. Based on my check, it's not possible to do with J2ME. How about Symbian? Is it possible?
Browsing around Stackoverflow, I get overwhelmed with the number of "Why should I learn Python/Ruby/PHP/.Net/jQuery..." and the list goes on. Most answers, although good, are usually battles from language A programmer to language B programmer detailing why one piece sucks more than another.
People can discuss the theoretical benefits of one over another but in the end, money/glitz talks and the rest walks. I am more interested in the potential opportunity that can come from one language or another over others. A little background, I am a project manager turned novice 'programmer' out of corporate necessity within the small company I currently work with so I have both relatively no set preference or experience, more out of curiosity. While I realize all are not created equal and for similar things, I think it would be interesting to start a list of the best websites / web applications built on specific languages/frameworks just to highlight the possibilities with each and give somebody like me motivation to say "How the heck was that done? Time to buy a book/take a class and learn."
Tell me and I will forget,
Show me and I will learn,
Involve me and I will understand
- Teton Lakota
In the case of an IM client. I have made 2 separate threads to handle sending packets (by std io) and receiving packets. The question is how to make these 2 threads run simultaneously so that I can keep prompting for input while at the same time be ready to receive packets at any time?
I have already tried setting a timer but the data is always lost receiving.