Deepak
*topic
lethal Robert
//Thank you @MissRose_bot
𝙡𝙚𝙗𝙚𝙣𝙨𝙡𝙖𝙣𝙜𝙚𝙧𝙨𝙘𝙝𝙞𝙘𝙠𝙨𝙖𝙡𝙨𝙨𝙘𝙝𝙖𝙩𝙯
/get cppbookguide
if i have a dynamic array of classes, what's the best way to add a new class to that array?
Pavel
if i have a dynamic array of classes, what's the best way to add a new class to that array?
Array of objects of a specific class? Like this? std::vector<MyClass> myVector; You can use push_back or emplace_back for example to add to the end of it.
I am not very good at c++ yet, now i have sth like this: Class *sth = new Class[10] and i want to get the size to 11
Alisher
You need to reallocate the memory for size 11
Seems like i have no other choice that to go and learn what exactly is std::vector
You need to reallocate the memory for size 11
some ppl on github said it is bad using realloc for classes in c++, i dont want to test it XD
Pavel
some ppl on github said it is bad using realloc for classes in c++, i dont want to test it XD
That's true, for a generic case you would need to allocate a new array and move every object there. Then to avoid extra constructor call, you would probably need to allocate raw memory instead of using arrays and manually construct and destruct objects there. Then to fight with the extra cost of allocations and movement, you would want to preallocate some memory in advance and store two sizes: allocated and used. Well, or use std::vector that does all that stuff for you :)
Anonymous
i hate signal races
Anonymous
Guys how can i get a free usa number help
Yazan
Hello
Yazan
Guys I have c++ exam Please someone help so urgent
Diego
Lmao we ain't going to solve your exam for you
Diego
If you've got any more specific questions, and some of us have free time, we may consider answering
Devjit
Hello everyone
Tecatito
Hello
zenn
Guys i have ( programming skill) mock exam today.please Can u guys help me ? B'coz i am new student
Ammar
Do your exam yourself.
zenn
Seriously? . I have no knowledge about programming . So i applied pvt campus .
Ammar
Seriously? . I have no knowledge about programming . So i applied pvt campus .
If you have no knowledge, then you can't pass the exam. It is really that simple.
zenn
Thats why i want to pass and I'm trying to do that course
zenn
I don't want to argue . If there is anyone who can help me. Please
Ammar
I don't want to argue . If there is anyone who can help me. Please
It is perfectly legal to ask for help for study. Especially specific part that you do not understand. But if what you ask is help in your exam, then it is academic dishonesty. Only people who understand the material should pass the exam.
-Arya!
I need someone to make a soft , If you have free time dm so I can explain what I exactly need ....
zenn
It is perfectly legal to ask for help for study. Especially specific part that you do not understand. But if what you ask is help in your exam, then it is academic dishonesty. Only people who understand the material should pass the exam.
You 're right because you do not understand my situation :).They select people who have studied IT. I did not do that subject. But I passed other subjects very well. That is why I have passed that examination. Need to learn programming. But anyway thanks for the reply
'''''''
Thnx
zenn
*Sri Lanka
Anonymous
i hate signal races
Signal races? Do you mean a race condition on a global structure because of an asynchronous signal handler?
'''''''
/report
Talula
Fact but not the group for it.
Anonymous
Signal races? Do you mean a race condition on a global structure because of an asynchronous signal handler?
no, like process signal races, eg kill(pid, signal), waitpid(pid, &status, flags)
Anonymous
https://gist.github.com/Total-Control-9985/7dafc08de8231a544c8c19853cb19c4f
Anonymous
Anonymous
ok, it is an issue with my join thread...
Anonymous
ok i have another race i need to figure out
Anonymous
by the time i send the SIGCONT and i wait for my process to change state to CONTINUE it may already have continued and exited before waitpid is called
Anonymous
/report
/report as bhakt
Anonymous
Anonymous
CASE STOPPED CONTINUE THREAD: 265096 EXITING waiting for CONTINUE pid 265096 WAIT TERMINATED CASE DEFAULT WAIT CASE TERMINATED JOINED
Anonymous
which, if fast enough, this can happen CONTINUE THREAD: 265485 EXITING waiting for CONTINUE pid 265485 WAIT TERMINATED JOINED
Talula
which, if fast enough, this can happen CONTINUE THREAD: 265485 EXITING waiting for CONTINUE pid 265485 WAIT TERMINATED JOINED
I thought you mean Propotional, integral and derivative when you said "PID loop"...
Anonymous
and i got another bug wait_for_state (pid 266027): unknown wait while waiting for state: CONTINUE
Talula
A proportional–integral–derivative controller (PID controller or three-term controller) is a control loop mechanism employing feedback that is widely used in industrial control systems and a variety of other applications requiring continuously modulated control. A PID controller continuously calculates an error value.
Anonymous
and i think the cause is this LOG_INFO("CONTINUE THREAD: %d", thread->pid.load()); thread->status = Thread::StatusList::RUNNING; sendSignal(thread, SIGCONT); if (getpid() != thread->pid) { LOG_INFO("WAITING FOR CONTINUE THREAD: %d", thread->pid.load()); waitForContinue(thread); LOG_INFO("WAITED FOR CONTINUE THREAD: %d", thread->pid.load()); } CONTINUE THREAD: 267012 boo! STOP THREAD: 267012 WAITING FOR CONTINUE THREAD: 267012 wait_for_state (pid 267011): unknown wait while waiting for state: CONTINUE
'''''''
Anonymous
which is another signal race
Anonymous
bloody signal races :(
Anonymous
but now i have a problem, waitForContinue(Thread * thread) CANNOT be used to wait for a STOP since it is meant to send SIGCONT to the program and then wait for the program to be delivered SIGCONT
Anonymous
as the program MAY do this: Prog1: kill(pid, SIGCONT); SCHED SWITCH Prog2 RECV SIGCONT Prog2: kill(self, SIGSTOP); Prog2 RECV SIGSTOP SCHED SWITCH Prog1: waitpid(pid, &status, WCONTINUED|WSTOPPED); /* check status for continue or termination */
Anonymous
eg https://gist.github.com/Total-Control-9985/94919d165d43f908560fdbb3f795715e
Anonymous
would i need to do this? https://gist.github.com/66bf4cd559b1b4b36261bc68cbc838d0
Anonymous
welp that helps but it is still not enough
Anonymous
STOP THREAD AND WAIT FOR CONTINUE: 272642 CONTINUE THREAD: 272642 boo! STOP THREAD AND WAIT FOR CONTINUE: 272642 wait_for_state (pid 272641): unknown wait while waiting for state: CONTINUE
Anonymous
think it is cus of this LOG_INFO("CONTINUE THREAD: %d", thread_pid); thread->status = Thread::StatusList::RUNNING; sendSignal(thread_pid, thread, SIGCONT); waitForContinue(thread); // we are sending a signal to ourself, so we must exist, no need to check for error kill(pid, SIGSTOP); // self cannot wait for SIGCONT since we are already in a continued state when kill returns while (thread->status != Thread::StatusList::RUNNING);
Anonymous
Anyone
search the Internet.
Anonymous
#cbook
Pankaj
/report
Anonymous
made a little script that continuously executes a command until output is matched and then outputs the entire output of that command if [[ $# < 2 ]] then echo "usage: $(basename $0) \"output to match against\" command <optional args>" fi string="$1" shift 1 cmd="$@" while true do rm UNTILLOUTPUTMATCHESEOF.txt > /dev/null 2>&1 script --flush --quiet --command "$cmd" UNTILLOUTPUTMATCHESEOF.txt # cmd might hang grep -q "$string" UNTILLOUTPUTMATCHESEOF.txt if [[ $? == 0 ]] then cat UNTILLOUTPUTMATCHESEOF.txt rm UNTILLOUTPUTMATCHESEOF.txt exit fi done
Anonymous
cus i dont wanna keep pressing up enter on my keyboard to try to find any bugs
Юрій
Can someone explain what`s wrong
Юрій
thread th1(LorisThread, s, socket_address);
Юрій
void LorisThread(SOCKET s, sockaddr_in* socket_address) {
Anonymous
use a paste site