{"comment":{"url":"https://api.github.com/repos/arduino/Arduino/comments/23903082","html_url":"https://github.com/arduino/Arduino/commit/ccd8880a37261b53ae11c666de0a29d85c28ae36#commitcomment-23903082","id":23903082,"user":{"login":"matthijskooijman","id":194491,"avatar_url":"https://avatars3.githubusercontent.com/u/194491?v=4","gravatar_id":"","url":"https://api.github.com/users/matthijskooijman","html_url":"https://github.com/matthijskooijman","followers_url":"https://api.github.com/users/matthijskooijman/followers","following_url":"https://api.github.com/users/matthijskooijman/following{/other_user}","gists_url":"https://api.github.com/users/matthijskooijman/gists{/gist_id}","starred_url":"https://api.github.com/users/matthijskooijman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthijskooijman/subscriptions","organizations_url":"https://api.github.com/users/matthijskooijman/orgs","repos_url":"https://api.github.com/users/matthijskooijman/repos","events_url":"https://api.github.com/users/matthijskooijman/events{/privacy}","received_events_url":"https://api.github.com/users/matthijskooijman/received_events","type":"User","site_admin":false},"position":36,"line":377,"path":"hardware/arduino/avr/cores/arduino/HardwareSerial.cpp","commit_id":"ccd8880a37261b53ae11c666de0a29d85c28ae36","created_at":"2017-08-27T08:49:40Z","updated_at":"2017-08-27T08:49:40Z","body":"> The 2nd is more problematic and should never happen if possible (user should not print in interrupts). However if we say users should not do that, then I do not see any reason why we do not use just this one:\r\n\r\nWell, the current policy is that printing in ISRs is not recommended, but it should be possible for debugging. In practice, this means that things will not break or deadlock, but it is acceptable to drop data or insert random garbage in the stream occasionally. So I do not agree that if *any* support for printing ISRs implies that there should be full support, there's still a balance there.\r\n\r\n> The TX Interrupt itself occurs while writing\r\n\r\nIn this case, I think the current code is already perfect and free of race conditions?\r\n\r\n> The 2nd option is really mad, as our write() can also get interrupted by another write(). For example if the buffer is full and we empty it, it doesnt mean right after that an interrupt fills it again. The only way to work around this is to completely disable interrupts in write() and possibly other functions(flush, etc.).\r\n\r\nAgreed (except I do not think this is \"mad\", it is something users might expect to just work).\r\n\r\n```\r\nwhile(bit_is_set(*_ucsra, UDRE0));\r\n_tx_udr_empty_irq();\r\n```\r\n\r\nI'm not sure where you envision this code exactly. Could you provide a larger snippet to show where this code will go?"}}
{"actor":{"display_login":"matthijskooijman"}}