i am working on mac application development,need help regarding connecting to remote system asynchronously with parallel execution.
How i can create 5 parallel threads in COCOA programming(at run time need to create based on count i.e 10 threads may be),
Need to connect to 5 MAC machines at a time based on thread count.
Please Guide me with SSH Wrapper and parallel execution of thread in COCOA(Mac) programming.
Thanks,
Shabana
Related
I'm developing a flask web application that requires a few tasks to be scheduled for the night time and was curious to pick some of your minds.
From the perspective of efficiency and performance of the application itself, would it be better to set up multiple supervisor program threads to each run a specific blocking APScheduler (at different times but same time frame), or to call all tasks back to back in 1 supervisor program thread with 1 blocking scheduler?
Thank you!
I am trying to understand what happens to a thread when it is waiting for a http response from remote server.
Let's say at one point in time n processes are running. The OS based on its thread scheduling algorithm will try to run every thread (Let's say on round robin fashion). Let's say one out of n thread has initiated a http request and waiting for response from remote server. Will this thread keep on getting its turn on cpu core? or is there some interrupt sort of mechanism which will notify the thread if it is ready to run? If interrupt sort of mechanism is present, then what is the benefit of using asynchronous programming? at-least from CPU utilization perspective.
Is the above thing language dependent? If yes, what is the difference between java vs nodejs vs python ...
I am trying to understand What happens to a thread when it is waiting
for a http response from remote server.
Well, the thread will wait for the underlying TCP socket to receive data. HTTP is a high level protocol that uses blocking/nonblocking TCP connection. as itself, the thread doesn't wait for an "HTTP response" but rather to some available data for the socket to read.
Will this thread keep on getting its turn on cpu core?
If the thread waits for a TCP socket to be readable, the OS doesn't schedule this thread to run until some data is received. then the OS will schedule the thread to run in some point in the future. blocked thread is never schedule to run - the OS doesn't see the reason to do so, considering the fact that the thread has nothing to do.
Is the above thing dependent on language? if yes what is the
difference between java vs nodejs vs python ...
No. Each OS provides a C/C++ API for application to consume. Windows provides Win32, while Linux provides POSIX. every programming language wraps and binds these APIs and every "high level" call (such as connecting a socket) will eventually call the operating system APIs.
My understanding is asynchronous keyword is used for your program to continue executing instead of waiting for the forked process to complete, even in single core processors, as was the case with early computers we were able to multitask, hence this could be deduced that the resource allocation was done by cpu while trying to be as judicious as it could be, so using async allows your thread of execution to execute without waiting for the blocking task to get completed, otherwise, even though cpu will take turns in executing a thread but since your program is a single thread it will block.
I am working for a client-server program using C language for Windows. Here I have to create 5 threads that will run concurrently and as soon as the client is connected, the free thread among 5 will interact with client. If none-of-the 5 threads are free the client will be prompted "Server busy try later... ". AS I am the newbie for multithreading, please suggest some solutions. Thankss.
(Requirement: The threads should be created either with _beginthread() or _beginthreadex()).
I am creating a web service that creates a huge amount of small java timer threads over (10k). I can only seem to create 2k timer threads before I get the OutOfMemoryError: unable to create new native thread. How do i solve this? I am using a macbook pro to run my Tomcat server on. I'v configured the ulimit (-u) max user processes to double what it used to be but I still get the same problem. What are my options, if any, to make this doable?
It's often a bad idea for web applications to start their own (few) threads, let alone 10K threads - and then "as timers"? Seriously? Don't go there.
What can you do?
Don't rely on the ability to create those threads.
Change your architecture! Use a scheduler library that has solved this problem already (e.g. Quartz or others).
If you don't want to use an external library (why wouldn't you?): Implement a single timer thread that executes the scheduled operations when they're due. Do not use a new thread for each scheduled operation
If you wanted to boil 100 eggs, would you buy 100 timers?
I run a daytime server on my own computer, it's a mac air laptop.
I want to test it's capability of concurrency. So I want to start massive concurrent client connecting to the daytime server. But what I come across is
a process can not start too many threads, it's limit is about 2000 threads per process, out out memory limitation.
I can not start too many process, since socket descriptor is limited ...
Therefore, how can I do the concurrency test, on the condition I do not have many other computers ...
You don't need many threads to have many connections. You don't need many processes to have many connections. It sounds like your real question is "how can I write a program that can handle large numbers of connections". On a Mac, the answer is kqueue. You can also use the Boost ASIO library which will call kqueue for you and gives you a nicer interface.