小编Gan*_*pur的帖子

socket descriptor vs file descriptor

read(2) and write(2) works both on socket descriptor as well as on file descriptor. In case of file descriptor, User file descriptor table->file table and finally to inode table where it checks for the file type(regular file/char/block), and reads accordingly. In case of char spl file, it gets the function pointers based on the major number of the file from the char device switch and calls the appropriate read/write routines registered for the device. Similarly appropriate read/write routine is called …

linux

11
推荐指数
2
解决办法
2万
查看次数

信号处理,中断处理问题

当进程正在执行阻塞系统调用时,例如读或写,信号已到达.系统调用是否因错误EINTR而终止?处理系统调用后是否重新启动系统调用?

假设,系统调用以错误EINTR终止,内核在返回用户空间之前处理信号.

信号句柄是在用户模式/内核模式下执行的吗?如果它处于用户模式,在系统调用(读/写)之后是否会返回指令,在此期间信号到达或在处理信号后再次进入内核模式并从ret_from_syscall返回给用户.如何在信号到达的系统调用旁边的指令处恢复执行?

是否可以通过在sigaction中传递SA_RESTART标志来重新启动系统?

linux linux-kernel

7
推荐指数
1
解决办法
2870
查看次数

以下代码有什么问题?它没有编译

#include <iostream> 
#include <vector>
using namespace std;

class Base
{
public:
      void Display( void )
      {
            cout<<"Base display"<<endl;
      }

      int Display( int a )
      {
            cout<<"Base int display"<<endl;
            return 0;
      }

};

class Derived : public Base
{
public:

      void Display( void )
      {
            cout<<"Derived display"<<endl;
      }
};


void main()
{
   Derived obj;
   obj.Display();  
   obj.Display( 10 );
}
Run Code Online (Sandbox Code Playgroud)
$test1.cpp: In function ‘int main()’:  
test1.cpp:35: error: no matching function for call to ‘Derived::Display(int)’  
test1.cpp:24: note: candidates are: void Derived::Display()
Run Code Online (Sandbox Code Playgroud)

在评论时obj.Display(10) …

c++

7
推荐指数
1
解决办法
197
查看次数

编译器如何知道您使用的函数是系统调用?

对于以下代码段,

int n;
char buf[100];
int fd = open ("/etc/passwd", O_RDONLY);
n = read ( fd, buf, 100);
Run Code Online (Sandbox Code Playgroud)

编译器如何知道read是系统调用而不是任何库函数?

它如何检索系统调用号(__NR_read)?

c linux system-calls

6
推荐指数
3
解决办法
3195
查看次数

c ++:下面一段代码崩溃了

#include <iostream>
using namespace std;

class B
{
public:
    B() { cout << "Base B()" << endl; }
    ~B() { cout << "Base ~B()" << endl; }
private:
    int x;
};

class D : public B
{
public:
    D() { cout << "Derived D()" << endl; }
    virtual ~D() { cout << "Derived ~D()" << endl; }
};

int
main ( void )
{
    B* b = new D;
    delete b;
}


---- output----------
Base B()
Derived D()
Base ~B() …
Run Code Online (Sandbox Code Playgroud)

c++ destructor

3
推荐指数
2
解决办法
537
查看次数

主题:一些问题

我对线程有几个问题.你能澄清一下吗?

  1. 假设有一个或多个线程的进程.如果进程被抢占/暂停,线程是否也被抢占或者线程是否继续运行?

  2. 当重新安排挂起的进程时,进程线程是否也会被调度?如果进程有进程有多个线程,哪些线程将被重新安排,以什么为基础?

  3. 如果进程中的线程正在运行并收到一个信号(比如Cntrl-C)并且信号的默认动作是终止进程,则正在运行的线程是终止还是父进程也会终止?如果运行进程由于某些信号而终止,那么线程会发生什么?

  4. 如果线程执行fork fallowed exec,exece'd程序是否覆盖父进程或正在运行的线程的地址空间?如果它覆盖父进程,线程,它们的数据,它们持有的锁以及exec'd进程终止后它们的调度方式会发生什么.

  5. 假设进程有多个线程,线程是如何调度的.如果其中一个线程阻塞某些I/O,则如何调度其他线程.与父进程一起调度的线程是否正在运行?

  6. 当线程正在运行当前内核变量指向的内容(父进程task_stuct或线程stack_struct?

  7. 如果具有该线程的进程正在运行,那么当该线程启动时,父进程是否被抢占以及每个线程如何被调度?

  8. 如果在CPU上运行的进程创建多个线程,那么父进程创建的线程是否在多处理器系统上的另一个CPU上调度?

谢谢,Ganesh

linux linux-kernel

2
推荐指数
1
解决办法
2224
查看次数

标签 统计

linux ×4

c++ ×2

linux-kernel ×2

c ×1

destructor ×1

system-calls ×1