Multi thread write to database in c++ [closed] - sql-server

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to use multithread to write data to MSSQL database in C++. Can I do it?
I think It can deadlocked or we must to wait. But I still want use multithread. Any idea?

Can I do it?
Can you program or are you willing to learn it? Because the "I" in the question is the critical thing. What you ask for is technically possible - but I have no idea whether you are capable of it.
I think It can deadlocked or we must to wait.
Generally every multi threaded data access MAY deadlock or wait. Which includes multi machine access - i.e. have hundreds of users accessing one database. Is there a question in there? The approaches to avoid deadlocks are well documented. Wait (i.e. wait for a writable lock) is also well documented.
But I still want use multithread. Any idea?
Learn enough programming to "just do it". Because this really is it - just do it.

Related

Doubts on storing CPU,RAM and DISK usage values [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have few doubts on database storage techniques:
How to store CPU usage activity to consider it for later use?
How to store RAM usage variation for a certain amount of time?
Similarly, how to store Disk usage?
All these data will be later used for ANOVA test.
I am trying to get these values from a c# application which will be monitoring the activities of a system for a certain amount of time.
A much better idea is to use the Performance Manager built into Windows (perfmon.exe). You can set it to record many performance items including the three you mention (CPU and RAM by program as well as in total). There is also a free analyser called PAL at Codeplex which can help you set the recording and then analyse it for you.

SQL Server isolation level, deadlocks across Load Ballancing [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I know what is DeadLock and how database generated. My goal is to clarify this issue thoroughly to record.
1- How can i handle deaed locks in sql server? Is there any library or tool to handle theme?
2- In a real time scenario how can i force while my database takes much requests in a short time. For example: i have 8 dedicated server and they are taking
20 000-40 000 per request in one second.
a-> Which is the best Load Balancing tool especially if i want to
escape the dead-locks
b-> Which layer is perfect for load balancing is it should be on
physical-layer or software-layer or both. Of course is both but how is
in your experiences? For example how is netscaler in physically? I
want to know their advantages and disadvantages?
This is a long formatted comment. In some of my ColdFusion applications, I have taken the following approach to handling deadlocks.
put the cfquery tag into a function that returns a ColdFusion query object.
Attempt to call that function using try/catch a maximum of 3 times
Throw an error if still unsucessful
This approach is not limited to ColdFusion. It can be applied to .net, php, java, and even tsql.
Also, it will not eliminate the deadlock problem. It will however, reduce the amount of times it happens.

Describe transactions and explain the main principles [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
could anyone help me answer this question:
Describe transactions and explain the main principles.
I think this link might be helpful
http://www.tutorialspoint.com/sqlite/sqlite_transactions.htm
There are many reasons for them. Among other reasons, transactions protect the integrity of your database data by allowing you to decide at the end of a session whether you want to commit the changes or revert back to the state the database was before you started making changes. Cases where you would want to revert back might be cases where an error occurs in your program while.
For example, if you are building a program for a bank that handles money transfers, you will likely make a query to update the balance in the customer's first account to be what it was minus the transfer amount. However, if you run into an error when attempting to update the second account, it would be nice to just abandon all the changes made and return both tables to their original state.
I hope the link helps.

How can a program run at specific time? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
(Sorry,I do a little change in my answer)
I want to know can I write a program that runs at a specific time?Is there any way to run a program automatically? And another question:Can I write a program that runs whenever another program is executed?
Note that it does not matter what the OS is,and I want a way to be in program code,that is I write a line of code that do the operation,because I cannot prompt different users to change their OS options to do the operation.
On windows you have the task scheduler, which can execute a programm at a specific time, with a specific user etc.
On linux you got something similar. The cronjobs/crontabs. An introduction you can find here.
based on new question:
What is the sense of this? You can't trigger your own program if it's not running. So basically your program must run in the background 24/7 and wait for events.
Maybe you should take a look at this post.
In windows you are having the task scheduler and the AT command. You refer this
link.
you need to develop a Daemon/Service process whose job is only to execute your application at required intervals or at specific time.

debug multi-threaded programs tips [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I wonder how to debug multi-threaded programs effectively.
What I've done so far:
I read some gdb reference, but all of them talk little about multi-thread debuging.
I used gdb to debug my c++ programs.
linux thread reference
What's your tricks to share?
Skills
1> Understand the code structure well. 2> Debug thread by thread. 3> In terms of exact time-stamps implemented.
PS: The approch still cannot solve my problem.
Disable watchdog
Assign each thread a unique id/name. This way you may get thread id inside any function and know for sure what thread executes it.
Learn how to use Threads Window in Visual Studio:
http://msdn.microsoft.com/en-us/library/w15yf86f.aspx
Using the debugger to understand a program might work well for single threaded systems.
It definitly doesn't work (well) for problems involving more then one thread. This is per design, as human nature is single threaded.
So to get into a multithreaded system:
Identify all threads and how they depend on another by reading and understanding the sources.
Debug each thread on its own. This might imply disabling or synchronising other threads.
Add detailed logging in terms of exact time-stamps implemented to not add synchronisation to the threads
This approach follows the paradigm of doing one thing at a time.

Resources