[{"data":1,"prerenderedAt":253},["ShallowReactive",2],{"project-23299972":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":29,"sentiment":30,"stance_mix":31,"scored_comments":36,"aspects":37,"strip":43,"post_text":46,"what":47,"said":77,"maker_in_thread":148,"shape":159,"grid":163,"attempts":217,"same_week":218,"maker_shows":44,"maker_hidden":246,"reader_version":247,"card":248},"23299972","avr_threads","Preemptive Multitasking on an AVR Microcontroller","title","Show HN: Preemptive Multitasking on an AVR Microcontroller","https:\u002F\u002Fgithub.com\u002FTurkeyMcMac\u002Favr_threads","github.com","jwmhjwmh",1590405584,2020,63,24,942,3028,32,"notable","languages","threading library for microcontrollers","library",[24,25,26,27,28],"avr","microcontroller","preemptive multitasking","context switching","avr-gcc","mixed",0.25,{"positive":32,"neutral":33,"mixed":34,"critical":35},6,4,0,2,12,{"execution":38,"idea":39,"performance":41,"docs":42},{"positive":34,"critical":34},{"positive":33,"critical":40},1,{"positive":34,"critical":34},{"positive":35,"critical":40},[34,44,34,34,34,34,34,34,44,45,45,44,34,40,34,45,44,40,34,45,45,34,34,45],3,5,null,{"problem":48,"audience":46,"pricing":46,"motivation":54,"time_to_build":46,"stack":62,"openness":75,"stage":76,"team_size":76},{"value":49,"source":50,"evidence":51},"Preemptive multitasking on an AVR microcontroller","maker",[52],{"id":53},"post",{"value":55,"source":56,"evidence":57},"Hacking interest; the maker said they see no practical use for it but find it interesting","commenter",[58],{"id":59,"by":60,"text":61},"23319850","andrewstuart","From the github: >> I do not see a practical use for this library, but I think it's interesting. +100 This is the essence of hacking.",[63,71],{"value":64,"source":65,"evidence":66},"AVR assembly","inferred",[67],{"id":68,"by":69,"text":70},"23320581","avian","I'm looking at these long series of pushes and pops [1]. You have 26 general-purpose registers plus X, Y, Z. I wonder if it would be possible to have e.g. only 4 threads and have…",{"value":72,"source":65,"evidence":73},"C",[74],{"id":68,"by":69,"text":70},"open_source","unknown",{"praise":78,"objections":100,"requests":112,"questions":124,"alternatives":129},[79,94],{"value":80,"source":56,"evidence":81},"Fun hacking project that revives nostalgia for building schedulers",[82,86,90],{"id":83,"by":84,"text":85},"23320425","magicalhippo","Ahhh this reminded me of when I as a teen saved up and bought \"Assembly Language Master Class\"[1], the only assembly-related book I could find in my local bookstore that didn't…",{"id":87,"by":88,"text":89},"23323017","snvzz",">Never got further, it was more of a \"can I do it\" type project, but boy that feeling when I saw my three \"processes\" running one after another without cooperation... priceless!…",{"id":91,"by":92,"text":93},"23325292","mmastrac","I love it. The next level of this hack would be integrating it with the Rust\u002FAVR work and building pseudo-threads with memory and thread safety on the platform (for no reason…",{"value":95,"source":56,"evidence":96},"Interesting exploration of how far software can be pushed on cheap chips",[97],{"id":98,"by":69,"text":99},"23324114","It's always interesting to explore how far a thing can be pushed software-wise. Copying bits is free and small AVRs are literally cents per piece in large quantities.",[101,105],{"value":102,"source":56,"evidence":103},"Register save\u002Frestore overhead is high; could use dedicated registers per thread",[104],{"id":68,"by":69,"text":70},{"value":106,"source":56,"evidence":107},"Missing explanation for flag values in source comments",[108],{"id":109,"by":110,"text":111},"23321730","kwhitefoot","> \u002F* Don't change these flag values! *\u002F Rant: It always annoys me when I see comments like this in the source. If it is important enough to implore people not to change something…",[113,117],{"value":114,"source":56,"evidence":115},"Add explanation for the flag constants in the code",[116],{"id":109,"by":110,"text":111},{"value":118,"source":56,"evidence":119},"Link to code instead of long inline snippets in comments",[120],{"id":121,"by":122,"text":123},"23322397","woodrowbarlow","cool code, but oof. can you make that a link to a pastebin? my scroll-wheel finger would thank you.",[125],{"value":126,"source":56,"evidence":127},"Can avr-gcc be made to limit register use for threaded C code",[128],{"id":68,"by":69,"text":70},[130,137,144],{"value":131,"source":56,"evidence":132},"Mantis OS for AVR ATmega128",[133],{"id":134,"by":135,"text":136},"23324873","goldenshale","I wrote a pre-emptive, multi-threaded OS for the AVR atmega 128 back in college as a sensor networking operating system called Mantis OS (mos). For anyone interested in this…",{"value":138,"source":56,"evidence":139},"kernelpanic, a UNIX-targeted toy preemptive OS",[140],{"id":141,"by":142,"text":143},"23325310","andrewguy9","I also wrote a preemptive threaded operating system for AVR atmega 128. At the start we had threads, pipes between threads, serial io, interrupts. After we finished the project,…",{"value":145,"source":56,"evidence":146},"seL4 microkernel",[147],{"id":87,"by":88,"text":89},{"comments":33,"answered":34,"key":149},[150,153,156],{"id":151,"text":152},"23321960","Yes, I also found it very rewarding when my scheduler eventually worked. Saving and restoring the registers was quite tricky. I eventually decided to just save them on the…",{"id":154,"text":155},"23322086","Maybe one could use the option -ffixed-reg and put different threads in different compilation units with different options. Even so, one would not be able to use the standard…",{"id":157,"text":158},"23322405","I wasn't planning on actually doing it, I was just thinking of how it could be done.",{"commenters":160,"max_depth":32,"maker_replies":33,"first_comment_mins":161,"lifespan_hours":162},16,2566,71,[164,166,169,173,175,177,180,183,185,187,189,192,194,195,199,201,202,204,206,209,212,214,215,216],[83,34,34,165,84,34],"commenter\u002Fneutral\u002Fnone",[167,34,44,168,84,34],"23321296","project\u002Fneutral\u002Fexecution",[170,34,34,171,172,34],"23321468","other\u002Fneutral\u002Fnone","TomMarius",[121,34,34,174,122,34],"commenter\u002Fneutral\u002Fdocs",[176,34,34,165,84,34],"23322556",[178,34,34,165,179,34],"23324810","omk",[181,34,34,165,182,34],"23325213","ComputerGuru",[151,34,34,184,11,40],"maker\u002Fneutral\u002Fexecution",[87,34,44,186,88,34],"project\u002Fneutral\u002Fidea",[59,40,45,188,60,34],"project\u002Fpositive\u002Fidea",[190,40,45,188,191,34],"23320210","Lerc",[68,35,44,193,69,34],"project\u002Fneutral\u002Fperformance",[154,35,34,193,11,40],[196,35,40,197,198,34],"23322347","project\u002Fcritical\u002Fidea","captncraig",[157,35,34,200,11,40],"maker\u002Fneutral\u002Fidea",[98,35,45,188,69,34],[203,35,44,168,182,34],"23325236",[109,44,40,205,110,34],"maker\u002Fcritical\u002Fdocs",[207,44,34,208,11,40],"23321913","maker\u002Fpositive\u002Fdocs",[210,44,45,208,211,34],"23324380","analognoise",[213,44,45,208,110,34],"23335521",[134,33,34,165,135,34],[141,33,34,165,142,34],[91,45,45,188,92,34],[],[219,224,229,233,238,242],{"id":220,"name":221,"points":222,"category":223},"23324598","Obsidian",1087,"productivity",{"id":225,"name":226,"points":227,"category":228},"23312339","Bear",685,"web_saas",{"id":230,"name":231,"points":232,"category":223},"23295989","Wiper",574,{"id":234,"name":235,"points":236,"category":237},"23282207","LaTeX.css",515,"dev_tools",{"id":239,"name":240,"points":241,"category":20},"23283880","neut",456,{"id":243,"name":244,"points":245,"category":223},"23255732","newscatcher",420,false,"v2",{"id":249,"name":5,"line":6,"ai":246,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":30,"top":18,"kw":250,"maker":11,"domain":10,"tier":19,"attempts":34,"strip":251,"url":9,"mix":252,"praise":80,"objection":102,"sub":21},23299972,[24,25,26,27,28],"030000003553010531055005",[32,33,34,35],1794036591043]