Go to advanced search

by Paeryn
Tue Jun 18, 2019 2:38 pm
Forum: C/C++
Topic: how to use pthread_kill(pthread_t tid, int sig) by which sig ?
Replies: 18
Views: 368

Re: how to use pthread_kill(pthread_t tid, int sig) by which sig ?

Just be careful with asynchronous cancels, there's no telling what the thread was doing when the cancel happens. Your cleanup functions should attempt to release any resources they have (file handles, allocated memory etc.) but if the thread got itself into a state where you aren't in control of it ...
by Paeryn
Tue Jun 18, 2019 1:22 pm
Forum: C/C++
Topic: how to use pthread_kill(pthread_t tid, int sig) by which sig ?
Replies: 18
Views: 368

Re: how to use pthread_kill(pthread_t tid, int sig) by which sig ?

I've added some example code to what you gave which will allow the watcher thread to cancel the uart thread. I had to change the order of starting the threads as the watcher thread needs the id of the uart thread. The pthread_cleanup_push() and pthread_cleanup_pop() functions are actually macros in ...
by Paeryn
Tue Jun 18, 2019 12:01 am
Forum: C/C++
Topic: how to use pthread_kill(pthread_t tid, int sig) by which sig ?
Replies: 18
Views: 368

Re: how to use pthread_kill(pthread_t tid, int sig) by which sig ?

Yes, I had a bad feeling it would do that. You probably should try a different signal (such as SIGTERM), catch it in the thread, and get the thread to terminate itself. SIGTERM will terminate the process as a whole as well. You might be able to use pthread_cancel(thread_id); That requests a thread ...
by Paeryn
Sat Jun 15, 2019 3:50 pm
Forum: C/C++
Topic: default priorities of user programs (single thread, pthread) and of programs run by the kernel ?
Replies: 13
Views: 420

Re: default priorities of user programs (single thread, pthread) and of programs run by the kernel ?

It should swap between them, the locked up one would ultimately prevent any lower priority thread from being run though. Again, it's a rough approximation of what happens, and with multi-core setups you have as many threads active as there are cores and threads will usually try to be kept on the sam...
by Paeryn
Sat Jun 15, 2019 12:20 am
Forum: C/C++
Topic: default priorities of user programs (single thread, pthread) and of programs run by the kernel ?
Replies: 13
Views: 420

Re: default priorities of user programs (single thread, pthread) and of programs run by the kernel ?

thank you for your hints and advices! As long as the higher priority thread doesn't continuously work (e.g. it sleeps or waits on other events) then you are ok, but if your priority 50 thread sits in a loop working 100% then any threads with a priority of less than 50 won't get a look in. but IIUC,...
by Paeryn
Thu Jun 13, 2019 8:50 pm
Forum: C/C++
Topic: default priorities of user programs (single thread, pthread) and of programs run by the kernel ?
Replies: 13
Views: 420

Re: default priorities of user programs (single thread, pthread) and of programs run by the kernel ?

PS, forgotten to ask...: if my pthreads have e.g. SCHED_RR prio=50 : which prio has a perpetual loop in main()? If a pthread by prio=50 hangs up completely, will it block then the main loop, too? And will a 2nd thread by prio=30 then also be blocked totally? int main() { // threads pthread_t thread...
by Paeryn
Thu Jun 13, 2019 2:10 am
Forum: C/C++
Topic: default priorities of user programs (single thread, pthread) and of programs run by the kernel ?
Replies: 13
Views: 420

Re: default priorities of user programs (single thread, pthread) and of programs run by the kernel ?

I'm not sure how threads at the same priority but with different schedulers are ordered with respect to others. All threads at pri=40 sched_rr will get equal run time (when the first finishes it goes to the back of its queue) but I don't know how it decides between a pri=40 sched_fifo thread and a p...
by Paeryn
Wed Jun 12, 2019 10:42 pm
Forum: C/C++
Topic: default priorities of user programs (single thread, pthread) and of programs run by the kernel ?
Replies: 13
Views: 420

Re: default priorities of user programs (single thread, pthread) and of programs run by the kernel ?

Normal user threads are scheduled with SCHED_OTHER and have a priority of 0 and a nice level between -20 and +19, the default nice level is 0. The higher its niceness is the lower its priority is, so a process with a niceness of 19 has the lowest priority. Only SCHED_OTHER uses the niceness level an...
by Paeryn
Tue Jun 11, 2019 11:40 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 543
Views: 14600

Re: A Final Fibonacci Challenge

I'm still getting seg faults trying to run the code. Can the C pros on this thread have a peek and help me figure out what the problem is or the best way to debug it? It gets to the first GMP::BI_ADD() function and seg faults. The original fibo function AIR helped out with works. My guess is SB doe...
by Paeryn
Tue Jun 11, 2019 9:52 pm
Forum: Python
Topic: How to print without newline
Replies: 6
Views: 260

Re: How to print without newline

Or use the fact that two string literals with only whitespace between them are implicitly converted into a single string at compile time rather than at run time (and you can use different quotation marks for each part if you want). $ cat strings.py print("This string is entered in two parts on separ...
by Paeryn
Tue Jun 11, 2019 8:05 pm
Forum: OpenGLES
Topic: undefined reference to BlendFuncSeparateOES
Replies: 5
Views: 491

Re: undefined reference to BlendFuncSeparateOES

At a guess, the driver (that is the one running on the VC4) doesn't support separate blend modes for alpha when running in an ES1 context. There's nothing preventing the hardware from doing it as blending is done in software on the QPUs but the driver that generates QPU code for ES1 might assume the...
by Paeryn
Tue Jun 11, 2019 5:27 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 543
Views: 14600

Re: A Final Fibonacci Challenge

There'll be leaks abound due to code like this res = mulis(fk, subis(mulis(fk1, "2"), fk)); Where the inner mulis allocates a string for the result which is passed to subis, when subis returns nobody has freed the string and its address is lost. Same with the string that subis returns and passes to ...
by Paeryn
Mon Jun 10, 2019 1:01 am
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 543
Views: 14600

Re: A Final Fibonacci Challenge

On my mobile phone (Android 7.1.1 with the default Chrome browser) I obtain the text The 4784969th Fibonacci Number is: Calculator:Preparing... (0/1) Sometimes nothing further happens; sometimes the big number appears after a few minutes. If I try to scroll to see the number, it disappears leaving ...
by Paeryn
Sat Jun 08, 2019 11:21 pm
Forum: C/C++
Topic: Weird artifacts on dot matrix display
Replies: 2
Views: 158

Re: Weird artifacts on dot matrix display

steven1578 wrote:
Sat Jun 08, 2019 9:28 pm
The problem however is shown in the video:
https://www.youtube.com/watch?v=8G8Ydv_b1eE
Could you describe what the problem is as, according to youtube, This video is unavailable?
by Paeryn
Sat Jun 08, 2019 2:43 am
Forum: Python
Topic: Remove empty string in list
Replies: 5
Views: 171

Re: Remove empty string in list

You could put a while around the input along these lines: invite_person = [] yesorno = "" while yesorno not in ['yes', 'no']: yesorno = input("Do you want to invite a person? ") yesorno = yesorno.strip() yesorno = yesorno.lower() while yesorno == "yes": enter_invite = input(str("Enter invitee's nam...
by Paeryn
Fri Jun 07, 2019 1:10 am
Forum: Python
Topic: Using button to display text in tKinter text wiget
Replies: 4
Views: 147

Re: Using button to display text in tKinter text wiget

Thanks for the reply, actually I did have the "root.mainloop" there it was the last line of the code but for some reason it got lost in the copy and paste. I have great difficulty finding tutorials for tkinter and python, a lot of example code not working. To give one simple example a lot of the ex...
by Paeryn
Fri Jun 07, 2019 12:43 am
Forum: Python
Topic: Print from function with yield
Replies: 2
Views: 97

Re: Print from function with yield

I learn Python and need help... Why this code prints all numbers def my_range(start, end, step): while start <= end: yield start start += step for x in my_range(1, 10, 0.5): print(x) but this dont: def my_range(start, end, step): while start <= end: yield start start += step (print(x) for x in my_r...
by Paeryn
Thu Jun 06, 2019 11:49 pm
Forum: C/C++
Topic: avoid compile warnings about ISO C++ forbids converting a string constant to ‘char*’
Replies: 24
Views: 1140

Re: avoid compile warnings about ISO C++ forbids converting a string constant to ‘char*’

swampdog, dsylexia123 is compiling the code as C++, not C (the clue is in the error message :roll: ), C++ will complain about attempts to pass string literals to non-const char* arguments as it violates the const-ness of string literals. The code only needs const adding in the function definitions (...
by Paeryn
Thu Jun 06, 2019 11:08 am
Forum: Troubleshooting
Topic: Can not change Pi password
Replies: 4
Views: 137

Re: Can not change Pi password

Hello, I am running stretch with all patches applied. I am trying to change the Pi password. In spite of indicating that it is successful, the password doesnt change. I am opting for a weak password hence sudo. sudo passwd Enter new UNIX password: Retype new UNIX password: passwd: password updated ...
by Paeryn
Thu Jun 06, 2019 4:07 am
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 543
Views: 14600

Re: A Final Fibonacci Challenge

@Paeryn Yes that version has some bugs . But Code: Select all realloc(fibs, sizeof(Fibs_struct)*fibs_size); Do you really want to realloc fibs and throw away it's new location if it got moved? Then What do I do? if the fibo ask is only 1 and the other 10000000. I gave an example, realloc() returns ...
by Paeryn
Thu Jun 06, 2019 2:47 am
Forum: General programming discussion
Topic: Is it possible to use my raspberri pi as a controller for a nintendo switch?
Replies: 4
Views: 184

Re: Is it possible to use my raspberri pi as a controller for a nintendo switch?

It should be possible, they are bluetooth controllers so you just need a driver that can read the controller and another that can emulate a controller for connecting to the Switch. Then have the emulated controller send the state that reader got, with any modifications you want to make. There's a L...
by Paeryn
Wed Jun 05, 2019 11:15 pm
Forum: Python
Topic: Using button to display text in tKinter text wiget
Replies: 4
Views: 147

Re: Using button to display text in tKinter text wiget

You don't seem to be running the Tk mainloop anywhere so no updates or events will be processed. You insert the text at the start of the Text object but without the mainloop running the Text object will never be redrawn. Usually Tk based programs are written in an event based manner where your progr...
by Paeryn
Wed Jun 05, 2019 4:44 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 543
Views: 14600

Re: A Final Fibonacci Challenge

ok I made one in C using tables of 32bits digits. It is not finished since I need to convert the result from hex to decimal. But it is blazzing fast. This version uses the same method than fibo.py. Since you don't want gmp, I made my own multiply and add fonction. #include <stdlib.h> #include <stdi...
by Paeryn
Wed Jun 05, 2019 3:33 pm
Forum: General programming discussion
Topic: Is it possible to use my raspberri pi as a controller for a nintendo switch?
Replies: 4
Views: 184

Re: Is it possible to use my raspberri pi as a controller for a nintendo switch?

It should be possible, they are bluetooth controllers so you just need a driver that can read the controller and another that can emulate a controller for connecting to the Switch. Then have the emulated controller send the state that reader got, with any modifications you want to make. There's a Li...
by Paeryn
Tue Jun 04, 2019 3:52 pm
Forum: Troubleshooting
Topic: GPIO4 Interrupt model 3b+ issue (?)
Replies: 14
Views: 261

Re: GPIO4 Interrupt model 3b+ issue (?)

Wouldn't you want a resistor between 3v3 and the GPIO rather than just a wire to limit the current?

Go to advanced search