📄 libssmp.s
字号:
/* * libssmp.S - runtime library code for SimpleScalar multiprocessor support * * This file is used in conjunction with the SimpleScalar tool suite * originally written by Todd M. Austin for the Multiscalar Research Project * at the University of Wisconsin-Madison. * * The file was created by Naraig Manjikian at Queen's University, * Kingston, Ontario, Canada. * * Copyright (C) 2000 by Naraig Manjikian * * This source file is distributed "as is" in the hope that it will be * useful. The tool set comes with no warranty, and no author or * distributor accepts any responsibility for the consequences of its * use. * * Everyone is granted permission to copy, modify and redistribute * this tool set under the following conditions: * * This source code is distributed for non-commercial use only. * Please contact the maintainer for restrictions applying to * commercial use. * * Permission is granted to anyone to make or distribute copies * of this source code, either as received or modified, in any * medium, provided that all copyright notices, permission and * nonwarranty notices are preserved, and that the distributor * grants the recipient permission for further redistribution as * permitted by this document. * * Permission is granted to distribute this file in compiled * or executable form under the same conditions that apply for * source code, provided that either: * * A. it is accompanied by the corresponding machine-readable * source code, * B. it is accompanied by a written offer, with no time limit, * to give anyone a machine-readable copy of the corresponding * source code in return for reimbursement of the cost of * distribution. This written offer must permit verbatim * duplication by anyone, or * C. it is distributed by someone who received only the * executable form, and is accompanied by a copy of the * written offer of source code that they received concurrently. * * In other words, you are welcome to use, share and improve this * source file. You are forbidden to forbid anyone else to use, share * and improve what you give them. *//* include #defines for system call codes specific to multiprocessing */#include "mpsyscall.h" .text/*---------------------------------------------------------------------*/ .align 2 .globl lock .ent locklock: li $2, SS_MP_ACQUIRE_LOCK syscall jr $31 .end lock/*---------------------------------------------------------------------*/ .align 2 .globl unlock .ent unlockunlock: li $2, SS_MP_RELEASE_LOCK syscall jr $31 .end unlock/*---------------------------------------------------------------------*/ .align 2 .globl init_lock .ent init_lockinit_lock: li $2, SS_MP_INIT_LOCK syscall jr $31 .end init_lock/*---------------------------------------------------------------------*/ .align 2 .globl barrier .ent barrierbarrier: li $2, SS_MP_BARRIER syscall jr $31 .end barrier/*---------------------------------------------------------------------*/ .align 2 .globl init_barrier .ent init_barrierinit_barrier: li $2, SS_MP_INIT_BARRIER syscall jr $31 .end init_barrier/*---------------------------------------------------------------------*/ .align 2 .globl get_my_thread_id .ent get_my_thread_idget_my_thread_id: li $2, SS_MP_THREAD_ID syscall jr $31 .end get_my_thread_id/*---------------------------------------------------------------------*/ .text .align 2 .globl create_thread .ent create_threadcreate_thread: la $5, thread_wrapper li $2, SS_MP_CREATE_THREAD syscall jr $31 .end create_thread/*---------------------------------------------------------------------*/ .text .align 2 .globl thread_wrapper .ent thread_wrapperthread_wrapper: jalr $31, $4 # call user-supplied function li $2, SS_MP_EXIT_THREAD # and then terminate syscall # thread exits, no return here jr $0 # THIS SHOULD NEVER BE EXECUTED !!! .end thread_wrapper/*---------------------------------------------------------------------*/ .align 2 .globl sema_wait .ent sema_waitsema_wait: li $2, SS_MP_SEMA_WAIT syscall jr $31 .end sema_wait/*---------------------------------------------------------------------*/ .align 2 .globl sema_signal .ent sema_signalsema_signal: li $2, SS_MP_SEMA_SIGNAL syscall jr $31 .end sema_signal/*---------------------------------------------------------------------*/ .align 2 .globl init_sema .ent init_semainit_sema: li $2, SS_MP_INIT_SEMA syscall jr $31 .end init_sema
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -