Changeset 90dd8aee in mainline for kernel/generic/src/printf/vprintf.c


Ignore:
Timestamp:
2025-04-10T17:55:36Z (4 days ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
8165a7a, c0d814a
Parents:
c55ab66
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-10 11:33:46)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-10 17:55:36)
Message:

Introduce a console lock to prevent line splitting in kernel output

It is a common occurrence to see broken lines on screen or in serial
output due to bad timing. This is an attempt to prevent that without
breaking anything.

It could be considered a stopgap solution, since the whole console
stack deserves a better/faster implementation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/printf/vprintf.c

    rc55ab66 r90dd8aee  
    3333 */
    3434
     35#include <arch/asm.h>
     36#include <console/console.h>
    3537#include <print.h>
    3638#include <printf/printf_core.h>
    3739#include <putchar.h>
     40#include <str.h>
    3841#include <synch/spinlock.h>
    39 #include <arch/asm.h>
    4042#include <typedefs.h>
    41 #include <str.h>
    4243
    4344static int vprintf_str_write(const char *str, size_t size, void *data)
     
    7475        char32_t uc;
    7576
     77        console_lock();
     78
    7679        while ((uc = str_decode(str, &offset, STR_NO_LIMIT)) != 0) {
    7780                putuchar(uc);
     
    8083
    8184        putuchar('\n');
     85
     86        console_unlock();
    8287        return chars;
    8388}
     
    9196        };
    9297
    93         return printf_core(fmt, &ps, ap);
     98        console_lock();
     99        int ret = printf_core(fmt, &ps, ap);
     100        console_unlock();
     101        return ret;
    94102}
    95103
Note: See TracChangeset for help on using the changeset viewer.