Changeset 5b303ba in mainline


Ignore:
Timestamp:
2007-04-07T17:57:07Z (18 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3dbe2d1f
Parents:
be66dee
Message:

use spinlock only on console output, not other print functions
cleanup

Location:
kernel/generic
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/print.h

    rbe66dee r5b303ba  
    4141
    4242/* We need this address in spinlock to avoid deadlock in deadlock detection */
    43 SPINLOCK_EXTERN(printflock);
     43SPINLOCK_EXTERN(printf_lock);
    4444
    4545#define EOF (-1)
  • kernel/generic/include/printf/printf_core.h

    rbe66dee r5b303ba  
    4848};
    4949
    50 int printf_core(const char *fmt, struct printf_spec *ps ,va_list ap);
     50int printf_core(const char *fmt, struct printf_spec *ps, va_list ap);
    5151
    5252#endif
  • kernel/generic/src/printf/printf_core.c

    rbe66dee r5b303ba  
    3939#include <putchar.h>
    4040#include <print.h>
    41 #include <synch/spinlock.h>
    4241#include <arch/arg.h>
    43 #include <arch/asm.h>
    44 
    4542#include <arch.h>
    46 
    47 SPINLOCK_INITIALIZE(printflock);                        /**< printf spinlock */
    4843
    4944#define __PRINTF_FLAG_PREFIX            0x00000001      /**< show prefixes 0x or 0*/
     
    459454int printf_core(const char *fmt, struct printf_spec *ps, va_list ap)
    460455{
    461         int irqpri;
    462456        int i = 0, j = 0; /**< i is index of currently processed char from fmt, j is index to the first not printed nonformating character */
    463457        int end;
     
    473467       
    474468        counter = 0;
    475        
    476         irqpri = interrupts_disable();
    477         spinlock_lock(&printflock);
    478 
     469               
    479470        while ((c = fmt[i])) {
    480471                /* control character */
     
    713704
    714705out:
    715         spinlock_unlock(&printflock);
    716         interrupts_restore(irqpri);
    717706       
    718707        return counter;
  • kernel/generic/src/printf/snprintf.c

    rbe66dee r5b303ba  
    5151/** @}
    5252 */
    53 
  • kernel/generic/src/printf/vprintf.c

    rbe66dee r5b303ba  
    3636#include <printf/printf_core.h>
    3737#include <putchar.h>
     38#include <synch/spinlock.h>
     39#include <arch/asm.h>
     40
     41SPINLOCK_INITIALIZE(printf_lock);                       /**< vprintf spinlock */
    3842
    3943static int vprintf_write(const char *str, size_t count, void *unused)
     
    5660{
    5761        struct printf_spec ps = {(int(*)(void *, size_t, void *)) vprintf_write, NULL};
    58         return printf_core(fmt, &ps, ap);
    59 
     62       
     63        int irqpri = interrupts_disable();
     64        spinlock_lock(&printf_lock);
     65       
     66        int ret = printf_core(fmt, &ps, ap);
     67       
     68        spinlock_unlock(&printf_lock);
     69        interrupts_restore(irqpri);
     70       
     71        return ret;
    6072}
    6173
  • kernel/generic/src/printf/vsnprintf.c

    rbe66dee r5b303ba  
    4343};
    4444
    45 int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data);
    46 
    4745/** Write string to given buffer.
    4846 * Write at most data->size characters including trailing zero. According to C99, snprintf() has to return number
     
    5553 * @return number of characters to print (not characters really printed!)
    5654 */
    57 int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data)
     55static int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data)
    5856{
    5957        size_t i;
  • kernel/generic/src/printf/vsprintf.c

    rbe66dee r5b303ba  
    3737int vsprintf(char *str, const char *fmt, va_list ap)
    3838{
    39         return vsnprintf(str, (size_t)-1, fmt, ap);
     39        return vsnprintf(str, (size_t) - 1, fmt, ap);
    4040}
    4141
Note: See TracChangeset for help on using the changeset viewer.