From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 7491439524A9 for ; Mon, 19 Jul 2021 14:39:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7491439524A9 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=luxonis.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=luxonis.com Received: by mail-lf1-x12f.google.com with SMTP id y42so30579118lfa.3 for ; Mon, 19 Jul 2021 07:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=luxonis.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=riptnxLKKmL4YAEayA7vUovhj/R3bmWWshpOlVMCl0Y=; b=KsXgUk8+7hKVKWraL9pW2eMivmJznVqr7EjES32jgSVABiH0viqrvbYwcc1g7J9NCT wB1ZSxYYgvHyBpjm78wnaAitm/iUX66hjLl5QOLSqBAjnC8+unR/Ru7TpdGm5k+k+QGx C0mgKm/mINEZyx/3BwEs0r8WsGCRaXdWjR1YiG1bPi7neGg0wtbuj95YW39ywN4MxwHb lC5k9Uagoigkwu7RIhqCcYOrbvj8e3MjSoUZUzbAHRLpNnGmUp1dTnOJbnf1E4tLmrUX R48+gSxdz61JzITS0Knfo3My7LZB/503TjKc8iHOp/TjpT0YbCr84+W4lNJSwXnvt7au Xdsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=riptnxLKKmL4YAEayA7vUovhj/R3bmWWshpOlVMCl0Y=; b=WNSEM9bzh9hHFCFbFmVBXinqshoKu1bTZcugHvgRdjCOY4fJxBqwB0DeprsE59goeZ ouVhdHp+MXZ39YUrCmGUPI8MPlX6gjnncyRY3Gqwb04YADEHTS8Yu/P3gzvtplFlNGes mb9DZJFvKnysJ/3QNNzr13UpbXfv24VoShCDsWF8ayAbQYmf+Pvlk4JMoReEc1wl6eiu SBGYb4l7Mu56/bwbzQGyE2iHG7s+7mfeEwA3Isb/70j/OrrIQl0KIRL05IIus8ho8njJ k1zpK9N3+bsk1fqZMZrE+6mrv9mS6n5s77KYPeC2Mz1RGVR5auLVh1ey2E6MiauUG+Ec +bwQ== X-Gm-Message-State: AOAM530CHw5Sc6t/aSeU3N6UIi3vIdls9tc46GaI9Jkv6bY6BdxuS0EY E+hkjrQJ/6NBUKo0MtX1Ok5pQsZqTAh4uEFPKDUF3sZ7l2hTUg== X-Google-Smtp-Source: ABdhPJzcfWb/MaL0oGnowAfAX+82gj30ExxsIACYoQq+cZf+r2wIVxjDWd26X/OjHJquiF8XrIa6o0sVZWu7TzSmknY= X-Received: by 2002:a05:6512:3d21:: with SMTP id d33mr18153770lfv.352.1626705548133; Mon, 19 Jul 2021 07:39:08 -0700 (PDT) MIME-Version: 1.0 From: Martin Peterlin Date: Mon, 19 Jul 2021 16:38:57 +0200 Message-ID: Subject: Question about locking in IO function To: newlib@sourceware.org X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jul 2021 14:39:11 -0000 Hi. I stumbled upon an issue on an embedded platform, where a thread was waiting for characters using fgetc(stdin) and another thread couldn't complete a fileno(stdin) call. The following snippet reproduces it: std::thread t1([](){ fgetc(stdin); }); std::this_thread::sleep_for(std::chrono::seconds(1)); printf("fileno(stdin): %d\n", fileno(stdin)); t1.join(); I ran this on both embedded platform and host, and host successfully executed fileno, while embedded platform got stuck on fileno, waiting for a mutex which was taken by fgetc. The embedded platform is supposedly running newlib-3.3.0 and host is Ubuntu 20.04 (glibc 2.31). Is this expected behavior? Is there a configuration option for some kind of multithreaded IO? I'm new to newlib and am not aware of all its possibilities and options. Best regards, Martin Peterlin