Deleted Added
full compact
subr_uio.c (207796) subr_uio.c (218195)
1/*-
2 * Copyright (c) 1982, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_subr.c 8.3 (Berkeley) 1/21/94
35 */
36
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)kern_subr.c 8.3 (Berkeley) 1/21/94
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/kern/subr_uio.c 207796 2010-05-08 20:34:01Z alc $");
38__FBSDID("$FreeBSD: head/sys/kern/subr_uio.c 218195 2011-02-02 16:35:10Z mdf $");
39
40#include "opt_zero.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>
45#include <sys/limits.h>
46#include <sys/lock.h>

--- 106 unchanged lines hidden (view full) ---

153 continue;
154 }
155 if (cnt > n)
156 cnt = n;
157
158 switch (uio->uio_segflg) {
159
160 case UIO_USERSPACE:
39
40#include "opt_zero.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>
45#include <sys/limits.h>
46#include <sys/lock.h>

--- 106 unchanged lines hidden (view full) ---

153 continue;
154 }
155 if (cnt > n)
156 cnt = n;
157
158 switch (uio->uio_segflg) {
159
160 case UIO_USERSPACE:
161 if (ticks - PCPU_GET(switchticks) >= hogticks)
162 uio_yield();
161 maybe_yield();
163 if (uio->uio_rw == UIO_READ)
164 error = copyout(cp, iov->iov_base, cnt);
165 else
166 error = copyin(iov->iov_base, cp, cnt);
167 if (error)
168 goto out;
169 break;
170

--- 107 unchanged lines hidden (view full) ---

278 continue;
279 }
280 if (cnt > n)
281 cnt = n;
282
283 switch (uio->uio_segflg) {
284
285 case UIO_USERSPACE:
162 if (uio->uio_rw == UIO_READ)
163 error = copyout(cp, iov->iov_base, cnt);
164 else
165 error = copyin(iov->iov_base, cp, cnt);
166 if (error)
167 goto out;
168 break;
169

--- 107 unchanged lines hidden (view full) ---

277 continue;
278 }
279 if (cnt > n)
280 cnt = n;
281
282 switch (uio->uio_segflg) {
283
284 case UIO_USERSPACE:
286 if (ticks - PCPU_GET(switchticks) >= hogticks)
287 uio_yield();
288
285 maybe_yield();
289 error = userspaceco(cp, cnt, uio, disposable);
286 error = userspaceco(cp, cnt, uio, disposable);
290
291 if (error)
292 return (error);
293 break;
294
295 case UIO_SYSSPACE:
296 if (uio->uio_rw == UIO_READ)
297 bcopy(cp, iov->iov_base, cnt);
298 else

--- 52 unchanged lines hidden (view full) ---

351 }
352 iov->iov_base = (char *)iov->iov_base + 1;
353 iov->iov_len--;
354 uio->uio_resid--;
355 uio->uio_offset++;
356 return (0);
357}
358
287 if (error)
288 return (error);
289 break;
290
291 case UIO_SYSSPACE:
292 if (uio->uio_rw == UIO_READ)
293 bcopy(cp, iov->iov_base, cnt);
294 else

--- 52 unchanged lines hidden (view full) ---

347 }
348 iov->iov_base = (char *)iov->iov_base + 1;
349 iov->iov_len--;
350 uio->uio_resid--;
351 uio->uio_offset++;
352 return (0);
353}
354
355int
356should_yield(void)
357{
358
359 return (ticks - PCPU_GET(switchticks) >= hogticks);
360}
361
359void
362void
363maybe_yield(void)
364{
365
366 if (should_yield())
367 uio_yield();
368}
369
370void
360uio_yield(void)
361{
362 struct thread *td;
363
364 td = curthread;
365 DROP_GIANT();
366 thread_lock(td);
367 sched_prio(td, td->td_user_pri);

--- 110 unchanged lines hidden ---
371uio_yield(void)
372{
373 struct thread *td;
374
375 td = curthread;
376 DROP_GIANT();
377 thread_lock(td);
378 sched_prio(td, td->td_user_pri);

--- 110 unchanged lines hidden ---