Changeset de33dab in mainline


Ignore:
Timestamp:
2007-04-09T13:53:57Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
183788f1
Parents:
d0b1443
Message:

Revert some of the changes introduced in revision 2209.
I think it is not correct to remove serialization of pseudo threads in printf_core.c.
With thread-level futex serialization, several pseudo threads running in one thread could easily deadlock
the task.

Add a dedicated futex serialization to thread1.c test only.

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/thread.c

    rd0b1443 rde33dab  
    661661                if (uspace_thread_id != NULL)
    662662                        return (unative_t) copy_to_uspace(uspace_thread_id, &t->tid,
    663                         sizeof(t->tid));
     663                            sizeof(t->tid));
    664664                else
    665665                        return 0;
  • uspace/libc/arch/sparc64/src/thread_entry.s

    rd0b1443 rde33dab  
    3535#
    3636__thread_entry:
    37         sethi %hi(_gp), %l7     
     37        sethi %hi(_gp), %l7
    3838        call __thread_main              ! %o0 contains address of uarg
    3939        or %l7, %lo(_gp), %l7
  • uspace/libc/generic/io/printf_core.c

    rd0b1443 rde33dab  
    4141#include <ctype.h>
    4242#include <string.h>
     43#include <async.h>      /* for pseudo thread serialization */
    4344
    4445#define __PRINTF_FLAG_PREFIX            0x00000001      /**< show prefixes 0x or 0*/
     
    443444        int width, precision;
    444445        uint64_t flags;
     446       
     447        /* Don't let other pseudo threads interfere. */
     448        async_serialize_start();
    445449       
    446450        counter = 0;
     
    675679        }
    676680       
     681        async_serialize_end();
    677682        return counter;
    678683minus_out:
     684        async_serialize_end();
    679685        return -counter;
    680686}
  • uspace/libc/generic/io/vprintf.c

    rd0b1443 rde33dab  
    3737#include <unistd.h>
    3838#include <io/printf_core.h>
    39 #include <futex.h>
    40 
    41 atomic_t printf_futex = FUTEX_INITIALIZER;
    4239
    4340static int vprintf_write(const char *str, size_t count, void *unused)
     
    5552        struct printf_spec ps = {(int(*)(void *, size_t, void *)) vprintf_write, NULL};
    5653       
    57         futex_down(&printf_futex);
    5854        int ret = printf_core(fmt, &ps, ap);
    59         futex_up(&printf_futex);
    6055       
    6156        return ret;
  • uspace/tester/fault/fault1.c

    rd0b1443 rde33dab  
    3434        ((int *)(0))[1] = 0;
    3535       
    36         return "Written to NULL";
     36        return "Survived write to NULL";
    3737}
  • uspace/tester/fault/fault2.c

    rd0b1443 rde33dab  
    3737        var1 = *((int *) (((char *) (&var)) + 1));
    3838       
    39         return "Done unaligned read";
     39        return "Survived unaligned read";
    4040}
  • uspace/tester/thread/thread1.c

    rd0b1443 rde33dab  
    3434#include <stdio.h>
    3535#include <unistd.h>
     36#include <futex.h>
    3637#include "../tester.h"
    3738
     
    4041static bool sh_quiet;
    4142
     43static atomic_t srlz = FUTEX_INITIALIZER;
     44
    4245static void threadtest(void *data)
    4346{
     
    4548
    4649        while (atomic_get(&finish)) {
    47                 if (!sh_quiet)
     50                if (!sh_quiet) {
     51                        futex_down(&srlz);
    4852                        printf("%llu ", thread_get_id());
     53                        futex_up(&srlz);
     54                }
    4955                usleep(100000);
    5056        }
     
    6975        }
    7076       
    71         if (!quiet)
     77        if (!quiet) {
     78                futex_down(&srlz);
    7279                printf("Running threads for 10 seconds...\n");
     80                futex_up(&srlz);
     81        }
    7382        sleep(10);
    7483       
Note: See TracChangeset for help on using the changeset viewer.