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

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.

Related

Multi thread write to database in c++ [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 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.

How the processor itself assumes the execution time of any program? [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
Suppose I have written some c programs.And the OS has SJF(shortest job first) scheduling policy so how will CPU decide the execution time for all the processes before actually executing them.Ex. every time whichever the short process that will be executed first in SJF.
As commented below, apparently Linux does not have a job control scripting language, so you should probably remove that tag, as well as the C tag.
On systems with job scheduling, there's some type of job control scripting language where the estimated run time is included in the information needed to run the job.
Example Wiki articles:
http://en.wikipedia.org/wiki/Job_Control_Language
In this case, the estimated time is specified as a job parameter:
/*JOBPARM TIME=10
for a time estimate of 10 minutes. On this web page, scroll down to the TIME parameter description:
http://www-01.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.ieab600/iea3b6_Parameter_definition5.htm
Based on the description, if the time is exceeded, the operator is notified. I'm not sure what happens on unattended systems.

How to write my own virtual machine like VirtualBox? [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
I would like to write virtual machine. Ideally I want to write program, which will be run(emulate) windows 7(from .iso) and show it in window on Windows 7 parent. But I can't understand how to do it. I understand how to emulate cpu, for example, just write wrapper(interface) which will be provide real cpu resources(http://www.codeproject.com/Articles/43176/How-to-create-your-own-virtual-machine), but what next? how to run OS, which will be use this abstraction interface of cpu. Bios starts OS, should I emulate bios? how to do it? From what should I start? Please, describe me the basic steps to implement my task.
Thank you very much!
I'm sure years and years of work go into these type of programs. However, to get a taste of emulating CPU and coding it yourself, have a look at nand2tetris.
It starts by looking at the logic and arithmetic first, slowly working your way towards program control, high-level language and making a operating system.
Hope this helps!
(BTW it provides all materials and software for free!)

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.

how to create a two process in c for linux operating system? [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
I want to achieve that one process should be keep on recieving the data from the client via the socket. another process is a timer task should be keep on running in parallel to call the tasks for every 2ms, 10ms and 100ms. I created a socket to recieve data and also the timer but i dont know how to run this task concurrently. could anyone help me by showing a example ??
It looks like threads might be a better option for you.
There is a nice comparison of threads and processes here: When is clone() and fork better than pthreads?
Try looking at these tutorial to get the idea how to program pthreads:
http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
you can use fork() system call to create a child process and run the task concurrently.

Resources