| Function report | 
| Source Code: ipc\sem.c | Create Date:2022-07-28 16:45:37 | 
| Last Modify:2020-03-12 14:18:49 | Copyright©Brick | 
| home page | Tree | 
| Annotation kernel can get tool activity | Download SCCT | Chinese | 
Name:do_semtimedop
Proto:static long do_semtimedop(int semid, struct sembuf __user *tsops, unsigned nsops, const struct timespec64 *timeout)
Type:long
Parameter:
| Type | Parameter | Name | 
|---|---|---|
| int | semid | |
| struct sembuf __user * | tsops | |
| unsigned | nsops | |
| const struct timespec64 * | timeout | 
| 1977 | dup = 0 , jiffies_left = 0 | 
| 1986 | If nsops > ~ 372 bytes on stack Then | 
| 1987 | sops = kvmalloc_array(nsops, size of sops , GFP_KERNEL) | 
| 1992 | If copy_from_user(sops, tsops, nsops * size of tsops ) Then | 
| 1997 | If timeout Then | 
| 1998 | If seconds < 0 || nanoseconds < 0 || nanoseconds >= 1000000000L Then | 
| 2003 | jiffies_left = timespec64_to_jiffies(timeout) | 
| 2006 | max = 0 | 
| 2008 | mask = 1ULL << semaphore index in array % BITS_PER_LONG | 
| 2010 | If semaphore index in array >= max Then max = semaphore index in array | 
| 2012 | If peration flags & undo the operation on exit Then undos = true | 
| 2021 | dupsop = true | 
| 2023 | If semaphore operation != 0 Then | 
| 2029 | If undos Then | 
| 2036 | Else | 
| 2037 | un = NULL | 
| 2041 | sma = sem_obtain_object_check(ns, semid) | 
| 2045 | Go to out_free | 
| 2049 | If max >= . of semaphores in array Then | 
| 2051 | Go to out_free | 
| 2057 | Go to out_free | 
| 2060 | error = security_sem_semop( & permissions .. see ipc.h , sops, nsops, alter) | 
| 2061 | If error Then | 
| 2063 | Go to out_free | 
| 2067 | locknum = If the request contains only one semaphore operation, and there are* no complex transactions pending, lock only the semaphore involved | 
| 2085 | If un && semaphore set identifier == -1 Then Go to out_unlock_free | 
| 2088 | array of pending operations = sops | 
| 2089 | umber of operations = nsops | 
| 2090 | undo structure = un | 
| 2092 | does *sops alter the array? = alter | 
| 2095 | error = perform_atomic_semop(sma, & queue) | 
| 2096 | If error == 0 Then | 
| 2108 | sem_unlock(sma, locknum) | 
| 2112 | Go to out_free | 
| 2114 | If error < 0 Then Go to out_unlock_free | 
| 2121 | If nsops == 1 Then | 
| 2126 | If alter Then | 
| 2127 | If pending complex operations Then | 
| 2130 | Else | 
| 2135 | Else | 
| 2138 | Else | 
| 2147 | pending complex operations ++ | 
| 2150 | Do | 
| 2151 | WRITE_ONCE(completion status of operation , - EINTR) | 
| 2152 | his process = current process | 
| 2155 | sem_unlock(sma, locknum) | 
| 2158 | If timeout Then jiffies_left = schedule_timeout - sleep until timeout*@timeout: timeout value in jiffies* Make the current task sleep until @timeout jiffies have* elapsed | 
| 2160 | Else schedule() | 
| 2174 | error = READ_ONCE(completion status of operation ) | 
| 2187 | locknum = If the request contains only one semaphore operation, and there are* no complex transactions pending, lock only the semaphore involved | 
| 2192 | error = READ_ONCE(completion status of operation ) | 
| 2198 | If error != -EINTR Then Go to out_unlock_free | 
| 2204 | If timeout && jiffies_left == 0 Then error = -EAGAIN | 
| 2206 | When error == -EINTR && Not signal_pending(current process) cycle | 
| 2208 | unlink_queue(sma, & queue) | 
| 2210 | out_unlock_free : | 
| 2211 | sem_unlock(sma, locknum) | 
| 2213 | out_free : | 
| 2216 | Return error | 
| Name | Describe | 
|---|---|
| ksys_semtimedop | |
| SYSCALL_DEFINE3 | 
| Source code conversion tool public plug-in interface | X | 
|---|---|
| Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |