net
but every time T2 sends a message, he has to to start a timer. if the timer expires before the ACK is received, he has to send that message again.
just need only one thread loop, design a state machine, from reading to sends to wait ACKs(and check timeout)
net
it's noticed that the wait ACKs state don't block on wait, use nonblocking mode, so you can check if received ACKs repeatly
Alex
i've never used a state machine and non-blocking mode lol but if the sending window is really big, maybe an ACK arrives when the thread is still sending stuff. what do you think?
Alex
yeah but with the Selective Repeat i need to send N numerated messages and wait for N numerated ACKs. when i receive the lowest number ACK, i send the N+1 message ecc
Alex
N = 4 send 0 send 1 send 2 send 3 receive ACK 0 send 4 receive ACK 1 send 5 ACK 2 and 3 maybe are lost, so the timer ends and he needs to send them again
net
N = 4 send 0 send 1 send 2 send 3 receive ACK 0 send 4 receive ACK 1 send 5 ACK 2 and 3 maybe are lost, so the timer ends and he needs to send them again
starting a new timer thread loop, providing a interface to add/erase timer handler, and that thread loop runs due timer handler repeatly.
net
yes, default is blocking, so waiting will timeout(may forever)
Alex
yes, default is blocking, so waiting will timeout(may forever)
yeah i know how can i use non blocking with the function recvfrom?
net
c - Making recvfrom() function non-blocking - Stack Overflow https://stackoverflow.com/questions/15941005/making-recvfrom-function-non-blocking
net
it seems that UDP has timeout option(if timeout, return immediately)
net
a general way is set fd to NON_BLOCK, and using select or epoll with timeout argument.
Alex
a general way is set fd to NON_BLOCK, and using select or epoll with timeout argument.
yeah, but then i don't know which timer has ended, because i need N timers, one for every msg sent
Alex
the server will send explicitly "i MSG" the client will send explicitly "ACK i" so no problem for that
net
the server will send explicitly "i MSG" the client will send explicitly "ACK i" so no problem for that
so the timer handler to tracks message number it sends, and sending timestamp. in timer thread loop, it can check which message needs resend
net
if it received ACKs, notify T1 to send next, and add timer.
Alex
so 2 threads are ok, right?
Puspam
You do it with: array[ index ] or you can use a pointer: int array[3] = { 1 , 2 , 3 }; int * array_ptr = array; Then access it with: *( array_ptr ) //will return 1 *( array_ptr + 1 * sizeof(int) ) //will return 2 *( array_ptr + 2 * sizeof(int) ) //will return 3
It's wrong. Since the array_ptr is of integer pointer type, it will already increment by 4 each time, so you need to increment array_ptr by 1, 2 & 3, not by sizeof(int).
conko
It doesn't create a new range. It is a view on top of your existing range. Nothing is copied.
You're right. A view rather than a range is created. Made this mistake by careless typing...
\Device\NUL
You may had cache miss when using stack to pass argument
mj12
> But compilers like Clang and GCC on optimisation level -O3 will not follow it precisely No, if they don't follow it precisely, it's a broken compiler.
Wrong, see https://en.cppreference.com/w/cpp/language/as_if If what you were saying was true, any compiler with the ability to inline function calls was "broken".
Alviro Iskandar
Wrong, see https://en.cppreference.com/w/cpp/language/as_if If what you were saying was true, any compiler with the ability to inline function calls was "broken".
if a *function call* is inlined, it's not a function call, so it doesn't follow the calling convention w.r.t. function call because the code is fully merged into a single subroutine what is the point of your objection?
mj12
if a *function call* is inlined, it's not a function call, so it doesn't follow the calling convention w.r.t. function call because the code is fully merged into a single subroutine what is the point of your objection?
that the original statement of "But compilers like Clang and GCC on optimisation level -O3 will not follow it precisely" is accurate. In practice, if you're not dealing with exported symbols, the compiler can and will generate *anything*.
Boom
You missed & in name[i]
is it necessary to point address of array?
Ammar
that the original statement of "But compilers like Clang and GCC on optimisation level -O3 will not follow it precisely" is accurate. In practice, if you're not dealing with exported symbols, the compiler can and will generate *anything*.
If the symbol is not exported, then it should be marked as static. The compiler can wildly optimize away static symbols because they are not used outside the translation unit.
mj12
Will not follow how? I agree that it can generate anything, *but* it must not violate the ABI. If it does, then it's definitely buggy.
Hence why i mentioned exported symbols. as long as the compiler (& to some extent the linker) can prove that whatever you're dealing with, it can generate any code, even breaking the ABI. (< as in, if you look at the layout of the data / calling conventions / whatever, it doesn't follow anything standardized.)
Alviro Iskandar
Hence why i mentioned exported symbols. as long as the compiler (& to some extent the linker) can prove that whatever you're dealing with, it can generate any code, even breaking the ABI. (< as in, if you look at the layout of the data / calling conventions / whatever, it doesn't follow anything standardized.)
I would love to get more explanation on this part: > even breaking the ABI I can't see the safe guarantee behind this, because if it's breaking the ABI, how come your program run properly? A calling convention exists to make each routine run without stepping on each others' toes. If you break this you don't have any way to call functions, syscalls, and anything that's ruled inside the ABI.
Alviro Iskandar
And I don't think inlined function is breaking the ABI. Because that is just a code merging and the resulting merge doesn't generate a function call. Just that. The ABI respects the resulting codegen, not the C/C++ code.
Ammar
I would love to get more explanation on this part: > even breaking the ABI I can't see the safe guarantee behind this, because if it's breaking the ABI, how come your program run properly? A calling convention exists to make each routine run without stepping on each others' toes. If you break this you don't have any way to call functions, syscalls, and anything that's ruled inside the ABI.
Hey, but wait... I think I remember you once discussed this with me on the lore. So yeah, he is right. Basically the compiler does some kind of escape analysis and if it can prove that the symbol is used internally, then it doesn't have to follow the defined calling convention. You, yourself once said: "The compiler thinks x() is static and will not clobber %r8d, even the ABI says %r8d will be clobbered by a function call. So i think it should be backported to the stable kernel, it's still a fix.". And you showed me an example on that day. Look at this: https://lore.kernel.org/lkml/CAOG64qPgTv5tQNknuG9d-=oL2EPQQ1ys7xu2FoBpNLyzv1qYzA@mail.gmail.com/
Ammar
Yup, this explains what i meant way better than i could've done. do you mind me DMing you some example i just dug up?
Why should be DM anyway? It would be great if Al and Faathin can read it on the group too.
mj12
I cannot post images here.
Ammar
I cannot post images here.
Ah right, please DM me, I will forward it to our GNU/Weeb group so they can see.
Ammar
Did this really get backported to stable kernel anyway? Lol.
It did get backported to the stable kernel. Already queued. Lookie here: https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git/tree/queue-5.15/x86-delay-fix-the-wrong-asm-constraint-in-delay_loop.patch
Anonymous
is it necessary to point address of array?
Yes as you are using subscript operator.so its the value and not the address. You can also use this if not using &, (array_name+i) which will return address of the i'th element.
Om
How to print palindrome number (it should be prime number as well) between given range??
Puspam
How to print palindrome number (it should be prime number as well) between given range??
Loop through the range. Check if the number is prime. Check if the number is a palindrome. If the number is both palindrome as well as prime, then print it.
Prakhar
#res
L
hi guys, can you please help me with this? its been hrs i dont know what is the problem and 2morrow is the exam day on DSA
L
https://pastebin.com/embed_js/rfAQandR
Anonymous
https://pastebin.com/embed_js/rfAQandR
Changes to head in insert will not affect head in main. You have to pass a pointer to head instead i.e. a node**
Anonymous
what do you mean i am passing a pointer to head
head will be a null pointer in main after insert returns. Here is an example void fun(int* ptr){ ptr = 0; } int main(){ int a = 10; int* p = &a; fun(p); } Here p will not become a null pointer after fun returns.
Amy
Maybe, you should pass a struct's pointer to insert. But that you have to change the codes of insert.
L
Thank you
Anonymous
Hi, How to safe programming in c ?!
Anonymous
Save?
No things! 😕
Lucas
ALTER EGO
Anonymous
use wisely scanf()
how to save spaces?
ALTER EGO
how to save spaces?
where to save?
Anonymous
where to save?
save a string containing spaces with scanf
ngdream
please how to send a link
ngdream
i want to send a code from my github repository
Anonymous
Read this
Ok thank you
ngdream
please can someone help me on my projects I am a student and I am currently on several projects in c++ as -jsinfinity: a javascript interpreter oriented for software creation (made with the v8 library) and -jstore: a store built around my jsinfinity interpreter which would make it possible to launch high-level applications without even having to download them, to reduce the weight occupied by the applications and etc. I need you to help me fix some bugs and tell me how I can configure my projects so that anyone can help me more easily on my projects also I have never worked on online projects with other people I would like to improve thank you for helping me Here are the links to my two repositories: contact me inbox if you want to help me
Ethan Raul
Hello I'm looking for someone to create mods for armored core games I've decided that trying to find someone to pay to make it happen would probably be the best thing as I do not possess the skill if anyone's interested please PM
Ethan Raul
Alternatively if you know somebody who would be up to the task I would love to meet them and talk to them to see if something can be worked out PM. Is open
Anonymous
Is friend function distroy the concept of oops ?
Shourya
Is friend function distroy the concept of oops ?
What do you mean by destroy oops? If you mean break encapsulation ..Read this https://isocpp.org/wiki/faq/friends#friends-and-encap
Amy
oops are just a concept, it should be in your head Instead of in the programs