简体   繁体   English

linux或任何OS中的黑白系统调用与用户调用的区别

[英]Difference b/w system calls & user calls in linux or any OS

I am searching for answer for many days but none of them solved my query. 我一直在寻找答案,但没有一个人解决了我的查询。 What is difference b/w system call & user call, I want to calculate USER CPU time & Kernel CPU time for printf() function in C. User cpu time is time taken by CPU to execute user routine & Kernel cpu time is time taken by cpu to execute kernel routine. 什么是黑白系统调用和用户调用的区别,我想计算C中printf()函数的USER CPU时间和内核CPU时间。用户cpu时间是CPU执行用户例程所花费的时间,而内核cpu时间是花费的时间由cpu执行内核例程。 My question is some where in calling printf() , In the end system call is invoked to print characters at display. 我的问题是在调用printf()的地方,最终系统调用被调用以在显示时打印字符。 I mean to say in routine printf() which part belongs to user & which part belongs to kernel. 我的意思是在例程printf()中说哪一部分属于用户,哪一部分属于内核。 Does simple assignment statement a=b involves system call? 简单赋值语句a = b是否涉及系统调用?

A simple a=b statement in C does not involve system calls; 用C语言编写的简单a=b语句不涉及系统调用。 this is completely executed in userspace. 这完全在用户空间中执行。

In printf() , most of the code is executed in userspace (eg. formatting of the supplied arguments). printf() ,大多数代码在用户空间中执行(例如,提供的参数的格式设置)。 Only for writing the final formatted text to stdout is the write system call invoked. 仅用于将最终格式化的文本write stdout时才调用write系统调用。 You can see this with the strace tool which shows all system calls made by an application. 您可以使用strace工具查看此信息,该工具显示了应用程序进行的所有系统调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM